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


Java DeleteRequest.version方法代碼示例

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


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

示例1: prepareRequest

import org.elasticsearch.action.delete.DeleteRequest; //導入方法依賴的package包/類
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));
    deleteRequest.routing(request.param("routing"));
    deleteRequest.parent(request.param("parent"));
    deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT));
    deleteRequest.setRefreshPolicy(request.param("refresh"));
    deleteRequest.version(RestActions.parseVersion(request));
    deleteRequest.versionType(VersionType.fromString(request.param("version_type"), deleteRequest.versionType()));

    String waitForActiveShards = request.param("wait_for_active_shards");
    if (waitForActiveShards != null) {
        deleteRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
    }

    return channel -> client.delete(deleteRequest, new RestStatusToXContentListener<>(channel));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,代碼來源:RestDeleteAction.java

示例2: ESDeleteTask

import org.elasticsearch.action.delete.DeleteRequest; //導入方法依賴的package包/類
public ESDeleteTask(UUID jobId,
                    ESDeleteNode node,
                    TransportDeleteAction transport,
                    JobContextService jobContextService) {
    super(jobId, node.executionPhaseId(), node.docKeys().size(), jobContextService);
    List<DeleteRequest> requests = new ArrayList<>(node.docKeys().size());
    List<ActionListener> listeners = new ArrayList<>(node.docKeys().size());
    for (DocKeys.DocKey docKey : node.docKeys()) {
        DeleteRequest request = new DeleteRequest(
                ESGetTask.indexName(node.tableInfo(), docKey.partitionValues()),
                Constants.DEFAULT_MAPPING_TYPE, docKey.id());
        request.routing(docKey.routing());
        if (docKey.version().isPresent()) {
            request.version(docKey.version().get());
        }
        requests.add(request);
        SettableFuture<TaskResult> result = SettableFuture.create();
        results.add(result);
        listeners.add(new DeleteResponseListener(result));
    }

    createContext("delete", requests, listeners, transport, null);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:24,代碼來源:ESDeleteTask.java

示例3: buildRequest

import org.elasticsearch.action.delete.DeleteRequest; //導入方法依賴的package包/類
@Override
protected RequestWrapper<DeleteRequest> buildRequest(ScrollableHitSource.Hit doc) {
    DeleteRequest delete = new DeleteRequest();
    delete.index(doc.getIndex());
    delete.type(doc.getType());
    delete.id(doc.getId());
    delete.version(doc.getVersion());
    return wrap(delete);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:AsyncDeleteByQueryAction.java

示例4: handleRequest

import org.elasticsearch.action.delete.DeleteRequest; //導入方法依賴的package包/類
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));
    deleteRequest.routing(request.param("routing"));
    deleteRequest.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing
    deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT));
    deleteRequest.refresh(request.paramAsBoolean("refresh", deleteRequest.refresh()));
    deleteRequest.version(RestActions.parseVersion(request));
    deleteRequest.versionType(VersionType.fromString(request.param("version_type"), deleteRequest.versionType()));

    String consistencyLevel = request.param("consistency");
    if (consistencyLevel != null) {
        deleteRequest.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel));
    }

    client.delete(deleteRequest, new RestBuilderListener<DeleteResponse>(channel) {
        @Override
        public RestResponse buildResponse(DeleteResponse result, XContentBuilder builder) throws Exception {
            ActionWriteResponse.ShardInfo shardInfo = result.getShardInfo();
            builder.startObject().field(Fields.FOUND, result.isFound())
                    .field(Fields._INDEX, result.getIndex())
                    .field(Fields._TYPE, result.getType())
                    .field(Fields._ID, result.getId())
                    .field(Fields._VERSION, result.getVersion())
                    .value(shardInfo)
                    .endObject();
            RestStatus status = shardInfo.status();
            if (!result.isFound()) {
                status = NOT_FOUND;
            }
            return new BytesRestResponse(status, builder);
        }
    });
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:35,代碼來源:RestDeleteAction.java

示例5: testDelete

import org.elasticsearch.action.delete.DeleteRequest; //導入方法依賴的package包/類
/**
 * This test documents docs/java-rest/high-level/document/delete.asciidoc
 */
public void testDelete() throws IOException {
    RestHighLevelClient client = highLevelClient();

    // tag::delete-request[]
    DeleteRequest request = new DeleteRequest(
        "index",    // <1>
        "type",     // <2>
        "id");      // <3>
    // end::delete-request[]

    // tag::delete-request-props[]
    request.timeout(TimeValue.timeValueSeconds(1));                     // <1>
    request.timeout("1s");                                              // <2>
    request.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL);    // <3>
    request.setRefreshPolicy("wait_for");                               // <4>
    request.version(2);                                                 // <5>
    request.versionType(VersionType.EXTERNAL);                          // <6>
    // end::delete-request-props[]

    // tag::delete-execute[]
    DeleteResponse response = client.delete(request);
    // end::delete-execute[]

    try {
        // tag::delete-notfound[]
        if (response.getResult().equals(DocWriteResponse.Result.NOT_FOUND)) {
            throw new Exception("Can't find document to be removed"); // <1>
        }
        // end::delete-notfound[]
    } catch (Exception ignored) { }

    // tag::delete-execute-async[]
    client.deleteAsync(request, new ActionListener<DeleteResponse>() {
        @Override
        public void onResponse(DeleteResponse deleteResponse) {
            // <1>
        }

        @Override
        public void onFailure(Exception e) {
            // <2>
        }
    });
    // end::delete-execute-async[]

    // tag::delete-conflict[]
    try {
        client.delete(request);
    } catch (ElasticsearchException exception) {
        if (exception.status().equals(RestStatus.CONFLICT)) {
            // <1>
        }
    }
    // end::delete-conflict[]

}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:60,代碼來源:DeleteDocumentationIT.java


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