当前位置: 首页>>代码示例>>Java>>正文


Java DocWriteRequest类代码示例

本文整理汇总了Java中org.elasticsearch.action.DocWriteRequest的典型用法代码示例。如果您正苦于以下问题:Java DocWriteRequest类的具体用法?Java DocWriteRequest怎么用?Java DocWriteRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DocWriteRequest类属于org.elasticsearch.action包,在下文中一共展示了DocWriteRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: add

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
/**
 * Adds a list of requests to be executed. Either index or delete requests.
 */
public BulkRequest add(Iterable<DocWriteRequest> requests) {
    for (DocWriteRequest request : requests) {
        add(request);
    }
    return this;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:BulkRequest.java

示例2: getBulkRequest

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
BulkRequest getBulkRequest() {
    if (itemResponses.isEmpty()) {
        return bulkRequest;
    } else {
        BulkRequest modifiedBulkRequest = new BulkRequest();
        modifiedBulkRequest.setRefreshPolicy(bulkRequest.getRefreshPolicy());
        modifiedBulkRequest.waitForActiveShards(bulkRequest.waitForActiveShards());
        modifiedBulkRequest.timeout(bulkRequest.timeout());

        int slot = 0;
        List<DocWriteRequest> requests = bulkRequest.requests();
        originalSlots = new int[requests.size()]; // oversize, but that's ok
        for (int i = 0; i < requests.size(); i++) {
            DocWriteRequest request = requests.get(i);
            if (failedSlots.get(i) == false) {
                modifiedBulkRequest.add(request);
                originalSlots[slot++] = i;
            }
        }
        return modifiedBulkRequest;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:TransportBulkAction.java

示例3: writeTo

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVInt(id);
    if (out.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) { // TODO remove once backported
        // old nodes expect updated version and version type on the request
        if (primaryResponse != null) {
            request.version(primaryResponse.getVersion());
            request.versionType(request.versionType().versionTypeForReplicationAndRecovery());
            DocWriteRequest.writeDocumentRequest(out, request);
        } else {
            DocWriteRequest.writeDocumentRequest(out, request);
        }
    } else {
        DocWriteRequest.writeDocumentRequest(out, request);
    }
    out.writeOptionalStreamable(primaryResponse);
    if (out.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) { // TODO remove once backported
        if (primaryResponse != null) {
            out.writeBoolean(primaryResponse.isFailed()
                    || primaryResponse.getResponse().getResult() == DocWriteResponse.Result.NOOP);
        } else {
            out.writeBoolean(false);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:BulkItemRequest.java

示例4: testIndexRequestOpTypeFromString

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testIndexRequestOpTypeFromString() throws Exception {
    String create = "create";
    String index = "index";
    String createUpper = "CREATE";
    String indexUpper = "INDEX";

    IndexRequest indexRequest = new IndexRequest("");
    indexRequest.opType(create);
    assertThat(indexRequest.opType() , equalTo(DocWriteRequest.OpType.CREATE));
    indexRequest.opType(createUpper);
    assertThat(indexRequest.opType() , equalTo(DocWriteRequest.OpType.CREATE));
    indexRequest.opType(index);
    assertThat(indexRequest.opType() , equalTo(DocWriteRequest.OpType.INDEX));
    indexRequest.opType(indexUpper);
    assertThat(indexRequest.opType() , equalTo(DocWriteRequest.OpType.INDEX));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:IndexRequestTests.java

示例5: testExecuteBulkIndexRequestWithRejection

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testExecuteBulkIndexRequestWithRejection() throws Exception {
    IndexMetaData metaData = indexMetaData();
    IndexShard shard = newStartedShard(true);

    BulkItemRequest[] items = new BulkItemRequest[1];
    DocWriteRequest writeRequest = new IndexRequest("index", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "foo", "bar");
    items[0] = new BulkItemRequest(0, writeRequest);
    BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);

    Translog.Location location = new Translog.Location(0, 0, 0);
    UpdateHelper updateHelper = null;

    // Pretend the mappings haven't made it to the node yet, and throw  a rejection
    Exception err = new ReplicationOperation.RetryOnPrimaryException(shardId, "rejection");

    try {
        TransportShardBulkAction.executeBulkItemRequest(metaData, shard, bulkShardRequest, location,
                0, updateHelper, threadPool::absoluteTimeInMillis, new ThrowingMappingUpdatePerformer(err));
        fail("should have thrown a retry exception");
    } catch (ReplicationOperation.RetryOnPrimaryException e) {
        assertThat(e, equalTo(err));
    }

    closeShards(shard);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:TransportShardBulkActionTests.java

示例6: testNoopUpdateReplicaRequest

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testNoopUpdateReplicaRequest() throws Exception {
    DocWriteRequest writeRequest = new IndexRequest("index", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
    BulkItemRequest replicaRequest = new BulkItemRequest(0, writeRequest);

    DocWriteResponse noopUpdateResponse = new UpdateResponse(shardId, "index", "id", 0, DocWriteResponse.Result.NOOP);
    BulkItemResultHolder noopResults = new BulkItemResultHolder(noopUpdateResponse, null, replicaRequest);

    Translog.Location location = new Translog.Location(0, 0, 0);
    BulkItemRequest[] items = new BulkItemRequest[0];
    BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
    Translog.Location newLocation = TransportShardBulkAction.updateReplicaRequest(noopResults,
            DocWriteRequest.OpType.UPDATE, location, bulkShardRequest);

    BulkItemResponse primaryResponse = replicaRequest.getPrimaryResponse();

    // Basically nothing changes in the request since it's a noop
    assertThat(newLocation, equalTo(location));
    assertThat(primaryResponse.getItemId(), equalTo(0));
    assertThat(primaryResponse.getId(), equalTo("id"));
    assertThat(primaryResponse.getOpType(), equalTo(DocWriteRequest.OpType.UPDATE));
    assertThat(primaryResponse.getResponse(), equalTo(noopUpdateResponse));
    assertThat(primaryResponse.getResponse().getResult(), equalTo(DocWriteResponse.Result.NOOP));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:TransportShardBulkActionTests.java

示例7: processDocumentActions

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void processDocumentActions(Stream<DocumentAction> documentActions)
{
	LOG.trace("Processing document actions ...");
	BulkProcessor bulkProcessor = bulkProcessorFactory.create(client);
	try
	{
		documentActions.forEachOrdered(documentAction ->
		{
			DocWriteRequest docWriteRequest = toDocWriteRequest(documentAction);
			bulkProcessor.add(docWriteRequest);
		});
	}
	finally
	{
		waitForCompletion(bulkProcessor);
		LOG.debug("Processed document actions.");
	}
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:19,代码来源:ClientFacade.java

示例8: setRandomVersion

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
private static void setRandomVersion(DocWriteRequest<?> request, Map<String, String> expectedParams) {
    if (randomBoolean()) {
        long version = randomFrom(Versions.MATCH_ANY, Versions.MATCH_DELETED, Versions.NOT_FOUND, randomNonNegativeLong());
        request.version(version);
        if (version != Versions.MATCH_ANY) {
            expectedParams.put("version", Long.toString(version));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:RequestTests.java

示例9: setRandomVersionType

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
private static void setRandomVersionType(DocWriteRequest<?> request, Map<String, String> expectedParams) {
    if (randomBoolean()) {
        VersionType versionType = randomFrom(VersionType.values());
        request.versionType(versionType);
        if (versionType != VersionType.INTERNAL) {
            expectedParams.put("version_type", versionType.name().toLowerCase(Locale.ROOT));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:RequestTests.java

示例10: hasIndexRequestsWithPipelines

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
/**
 * @return Whether this bulk request contains index request with an ingest pipeline enabled.
 */
public boolean hasIndexRequestsWithPipelines() {
    for (DocWriteRequest actionRequest : requests) {
        if (actionRequest instanceof IndexRequest) {
            IndexRequest indexRequest = (IndexRequest) actionRequest;
            if (Strings.hasText(indexRequest.getPipeline())) {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:BulkRequest.java

示例11: readFrom

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    waitForActiveShards = ActiveShardCount.readFrom(in);
    int size = in.readVInt();
    for (int i = 0; i < size; i++) {
        requests.add(DocWriteRequest.readDocumentRequest(in));
    }
    refreshPolicy = RefreshPolicy.readFrom(in);
    timeout = new TimeValue(in);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:BulkRequest.java

示例12: writeTo

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    waitForActiveShards.writeTo(out);
    out.writeVInt(requests.size());
    for (DocWriteRequest request : requests) {
        DocWriteRequest.writeDocumentRequest(out, request);
    }
    refreshPolicy.writeTo(out);
    timeout.writeTo(out);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:BulkRequest.java

示例13: setResponseFailureIfIndexMatches

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
private boolean setResponseFailureIfIndexMatches(AtomicArray<BulkItemResponse> responses, int idx, DocWriteRequest request, String index, Exception e) {
    if (index.equals(request.index())) {
        responses.set(idx, new BulkItemResponse(idx, request.opType(), new BulkItemResponse.Failure(request.index(), request.type(), request.id(), e)));
        return true;
    }
    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:TransportBulkAction.java

示例14: resolveIfAbsent

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
Index resolveIfAbsent(DocWriteRequest request) {
    Index concreteIndex = indices.get(request.index());
    if (concreteIndex == null) {
        concreteIndex = indexNameExpressionResolver.concreteSingleIndex(state, request);
        indices.put(request.index(), concreteIndex);
    }
    return concreteIndex;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:TransportBulkAction.java

示例15: shardOperationOnReplica

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
@Override
protected WriteReplicaResult<Request> shardOperationOnReplica(
    Request replicaRequest, IndexShard replica) throws Exception {
    BulkItemRequest[] itemRequests = new BulkItemRequest[1];
    WriteRequest.RefreshPolicy refreshPolicy = replicaRequest.getRefreshPolicy();
    itemRequests[0] = new BulkItemRequest(0, ((DocWriteRequest) replicaRequest));
    BulkShardRequest bulkShardRequest = new BulkShardRequest(replicaRequest.shardId(), refreshPolicy, itemRequests);
    WriteReplicaResult<BulkShardRequest> result = shardBulkAction.shardOperationOnReplica(bulkShardRequest, replica);
    // a replica operation can never throw a document-level failure,
    // as the same document has been already indexed successfully in the primary
    return new WriteReplicaResult<>(replicaRequest, result.location, null, replica, logger);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:TransportSingleItemBulkWriteAction.java


注:本文中的org.elasticsearch.action.DocWriteRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。