當前位置: 首頁>>代碼示例>>Java>>正文


Java IndexRequest.type方法代碼示例

本文整理匯總了Java中org.elasticsearch.action.index.IndexRequest.type方法的典型用法代碼示例。如果您正苦於以下問題:Java IndexRequest.type方法的具體用法?Java IndexRequest.type怎麽用?Java IndexRequest.type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.action.index.IndexRequest的用法示例。


在下文中一共展示了IndexRequest.type方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shardIndexOperation

import org.elasticsearch.action.index.IndexRequest; //導入方法依賴的package包/類
private WriteResult<IndexResponse> shardIndexOperation(BulkShardRequest request, IndexRequest indexRequest, MetaData metaData,
                                        IndexShard indexShard, boolean processed) throws Throwable {
    indexShard.checkDiskSpace(fsService);
    // validate, if routing is required, that we got routing
    MappingMetaData mappingMd = metaData.index(request.index()).mappingOrDefault(indexRequest.type());
    if (mappingMd != null && mappingMd.routing().required()) {
        if (indexRequest.routing() == null) {
            throw new RoutingMissingException(request.index(), indexRequest.type(), indexRequest.id());
        }
    }

    if (!processed) {
        indexRequest.process(metaData, mappingMd, allowIdGeneration, request.index());
    }

    return TransportIndexAction.executeIndexRequestOnPrimary(request, indexRequest, indexShard, mappingUpdatedAction);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:18,代碼來源:TransportShardBulkAction.java

示例2: buildRequest

import org.elasticsearch.action.index.IndexRequest; //導入方法依賴的package包/類
@Override
protected RequestWrapper<IndexRequest> buildRequest(ScrollableHitSource.Hit doc) {
    IndexRequest index = new IndexRequest();
    index.index(doc.getIndex());
    index.type(doc.getType());
    index.id(doc.getId());
    index.source(doc.getSource(), doc.getXContentType());
    index.versionType(VersionType.INTERNAL);
    index.version(doc.getVersion());
    index.setPipeline(mainRequest.getPipeline());
    return wrap(index);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:TransportUpdateByQueryAction.java

示例3: innerExecute

import org.elasticsearch.action.index.IndexRequest; //導入方法依賴的package包/類
private void innerExecute(IndexRequest indexRequest, Pipeline pipeline) throws Exception {
    if (pipeline.getProcessors().isEmpty()) {
        return;
    }

    long startTimeInNanos = System.nanoTime();
    // the pipeline specific stat holder may not exist and that is fine:
    // (e.g. the pipeline may have been removed while we're ingesting a document
    Optional<StatsHolder> pipelineStats = Optional.ofNullable(statsHolderPerPipeline.get(pipeline.getId()));
    try {
        totalStats.preIngest();
        pipelineStats.ifPresent(StatsHolder::preIngest);
        String index = indexRequest.index();
        String type = indexRequest.type();
        String id = indexRequest.id();
        String routing = indexRequest.routing();
        String parent = indexRequest.parent();
        Map<String, Object> sourceAsMap = indexRequest.sourceAsMap();
        IngestDocument ingestDocument = new IngestDocument(index, type, id, routing, parent, sourceAsMap);
        pipeline.execute(ingestDocument);

        Map<IngestDocument.MetaData, String> metadataMap = ingestDocument.extractMetadata();
        //it's fine to set all metadata fields all the time, as ingest document holds their starting values
        //before ingestion, which might also get modified during ingestion.
        indexRequest.index(metadataMap.get(IngestDocument.MetaData.INDEX));
        indexRequest.type(metadataMap.get(IngestDocument.MetaData.TYPE));
        indexRequest.id(metadataMap.get(IngestDocument.MetaData.ID));
        indexRequest.routing(metadataMap.get(IngestDocument.MetaData.ROUTING));
        indexRequest.parent(metadataMap.get(IngestDocument.MetaData.PARENT));
        indexRequest.source(ingestDocument.getSourceAndMetadata());
    } catch (Exception e) {
        totalStats.ingestFailed();
        pipelineStats.ifPresent(StatsHolder::ingestFailed);
        throw e;
    } finally {
        long ingestTimeInMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTimeInNanos);
        totalStats.postIngest(ingestTimeInMillis);
        pipelineStats.ifPresent(statsHolder -> statsHolder.postIngest(ingestTimeInMillis));
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:41,代碼來源:PipelineExecutionService.java

示例4: executeIndexRequest

import org.elasticsearch.action.index.IndexRequest; //導入方法依賴的package包/類
private static BulkItemResultHolder executeIndexRequest(final IndexRequest indexRequest,
                                                        final BulkItemRequest bulkItemRequest,
                                                        final IndexShard primary,
                                                        final MappingUpdatePerformer mappingUpdater) throws Exception {
    Engine.IndexResult indexResult = executeIndexRequestOnPrimary(indexRequest, primary, mappingUpdater);
    if (indexResult.hasFailure()) {
        return new BulkItemResultHolder(null, indexResult, bulkItemRequest);
    } else {
        IndexResponse response = new IndexResponse(primary.shardId(), indexRequest.type(), indexRequest.id(),
                indexResult.getSeqNo(), indexResult.getVersion(), indexResult.isCreated());
        return new BulkItemResultHolder(response, indexResult, bulkItemRequest);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:14,代碼來源:TransportShardBulkAction.java

示例5: markCurrentItemAsFailed

import org.elasticsearch.action.index.IndexRequest; //導入方法依賴的package包/類
void markCurrentItemAsFailed(Exception e) {
    IndexRequest indexRequest = (IndexRequest) bulkRequest.requests().get(currentSlot);
    // We hit a error during preprocessing a request, so we:
    // 1) Remember the request item slot from the bulk, so that we're done processing all requests we know what failed
    // 2) Add a bulk item failure for this request
    // 3) Continue with the next request in the bulk.
    failedSlots.set(currentSlot);
    BulkItemResponse.Failure failure = new BulkItemResponse.Failure(indexRequest.index(), indexRequest.type(), indexRequest.id(), e);
    itemResponses.add(new BulkItemResponse(currentSlot, indexRequest.opType(), failure));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:TransportBulkAction.java

示例6: indexOnPrimary

import org.elasticsearch.action.index.IndexRequest; //導入方法依賴的package包/類
/**
 * indexes the given requests on the supplied primary, modifying it for replicas
 */
protected IndexResponse indexOnPrimary(IndexRequest request, IndexShard primary) throws Exception {
    final Engine.IndexResult indexResult = executeIndexRequestOnPrimary(request, primary,
            new TransportShardBulkActionTests.NoopMappingUpdatePerformer());
    request.primaryTerm(primary.getPrimaryTerm());
    TransportWriteActionTestHelper.performPostWriteActions(primary, request, indexResult.getTranslogLocation(), logger);
    return new IndexResponse(
        primary.shardId(),
        request.type(),
        request.id(),
        indexResult.getSeqNo(),
        indexResult.getVersion(),
        indexResult.isCreated());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,代碼來源:ESIndexLevelReplicationTestCase.java

示例7: testPipelineFailures

import org.elasticsearch.action.index.IndexRequest; //導入方法依賴的package包/類
public void testPipelineFailures() {
    BulkRequest originalBulkRequest = new BulkRequest();
    for (int i = 0; i < 32; i++) {
        originalBulkRequest.add(new IndexRequest("index", "type", String.valueOf(i)));
    }

    TransportBulkAction.BulkRequestModifier modifier = new TransportBulkAction.BulkRequestModifier(originalBulkRequest);
    for (int i = 0; modifier.hasNext(); i++) {
        modifier.next();
        if (i % 2 == 0) {
            modifier.markCurrentItemAsFailed(new RuntimeException());
        }
    }

    // So half of the requests have "failed", so only the successful requests are left:
    BulkRequest bulkRequest = modifier.getBulkRequest();
    assertThat(bulkRequest.requests().size(), Matchers.equalTo(16));

    List<BulkItemResponse> responses = new ArrayList<>();
    ActionListener<BulkResponse> bulkResponseListener = modifier.wrapActionListenerIfNeeded(1L, new ActionListener<BulkResponse>() {
        @Override
        public void onResponse(BulkResponse bulkItemResponses) {
            responses.addAll(Arrays.asList(bulkItemResponses.getItems()));
        }

        @Override
        public void onFailure(Exception e) {
        }
    });

    List<BulkItemResponse> originalResponses = new ArrayList<>();
    for (DocWriteRequest actionRequest : bulkRequest.requests()) {
        IndexRequest indexRequest = (IndexRequest) actionRequest;
        IndexResponse indexResponse = new IndexResponse(new ShardId("index", "_na_", 0), indexRequest.type(),
                                                           indexRequest.id(), 1, 1, true);
        originalResponses.add(new BulkItemResponse(Integer.parseInt(indexRequest.id()), indexRequest.opType(), indexResponse));
    }
    bulkResponseListener.onResponse(new BulkResponse(originalResponses.toArray(new BulkItemResponse[originalResponses.size()]), 0));

    assertThat(responses.size(), Matchers.equalTo(32));
    for (int i = 0; i < 32; i++) {
        assertThat(responses.get(i).getId(), Matchers.equalTo(String.valueOf(i)));
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:45,代碼來源:BulkRequestModifierTests.java


注:本文中的org.elasticsearch.action.index.IndexRequest.type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。