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


Java DeleteRequest.type方法代碼示例

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


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

示例1: should_marshall_delete_request

import org.elasticsearch.action.delete.DeleteRequest; //導入方法依賴的package包/類
@Test
public void should_marshall_delete_request() throws Exception {
    DeleteRequest request = new DeleteRequest();
    request.index("the_index");
    request.type("the_type");
    request.id("the_id");
    Observable<byte[]> observable = BulkActionMarshaller.lazyConvertToBytes(Collections.<ActionRequest>singletonList(request));
    assertHasSize(observable, 2);

    byte[] bytes = takeNth(observable, 0);
    String actionAsString = new String(bytes);
    assertThat(actionAsString).isEqualTo("{\"delete\":{\"_index\":\"the_index\",\"_type\":\"the_type\",\"_id\":\"the_id\"}}");

    bytes = takeNth(observable, 1);
    assertThat(new String(bytes)).isEqualTo("\n");
}
 
開發者ID:obourgain,項目名稱:elasticsearch-http,代碼行數:17,代碼來源:BulkActionMarshallerTest.java

示例2: 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

示例3: executeDeleteRequest

import org.elasticsearch.action.delete.DeleteRequest; //導入方法依賴的package包/類
private static BulkItemResultHolder executeDeleteRequest(final DeleteRequest deleteRequest,
                                                         final BulkItemRequest bulkItemRequest,
                                                         final IndexShard primary) throws IOException {
    Engine.DeleteResult deleteResult = executeDeleteRequestOnPrimary(deleteRequest, primary);
    if (deleteResult.hasFailure()) {
        return new BulkItemResultHolder(null, deleteResult, bulkItemRequest);
    } else {
        DeleteResponse response = new DeleteResponse(primary.shardId(), deleteRequest.type(), deleteRequest.id(),
                deleteResult.getSeqNo(), deleteResult.getVersion(), deleteResult.isFound());
        return new BulkItemResultHolder(response, deleteResult, bulkItemRequest);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:TransportShardBulkAction.java

示例4: execute

import org.elasticsearch.action.delete.DeleteRequest; //導入方法依賴的package包/類
public void execute(final DeleteRequest request, final ActionListener<DeleteResponse> listener) {
    logger.debug("delete request " + request);
    try {
        RequestUriBuilder uriBuilder = new RequestUriBuilder(request.index(), request.type(), URLEncoder.encode(request.id(), Charsets.UTF_8.displayName()));

        uriBuilder.addQueryParameterIfNotZero("version", request.version());
        uriBuilder.addQueryParameterIfNotNull("routing", request.routing());

        uriBuilder.addVersionType(request.versionType());
        uriBuilder.addConsistencyLevel(request.consistencyLevel());

        if (request.refresh()) {
            uriBuilder.addQueryParameter("refresh", true);
        }
        if (request.timeout() != ShardReplicationOperationRequest.DEFAULT_TIMEOUT) {
            uriBuilder.addQueryParameter("timeout", request.timeout().toString());
        }

        httpClient.getHttpClient().submit(HttpClientRequest.createDelete(uriBuilder.toString()))
                .flatMap(ErrorHandler.AS_FUNC)
                .flatMap(new Func1<HttpClientResponse<ByteBuf>, Observable<DeleteResponse>>() {
                    @Override
                    public Observable<DeleteResponse> call(HttpClientResponse<ByteBuf> response) {
                        return response.getContent().flatMap(new Func1<ByteBuf, Observable<DeleteResponse>>() {
                            @Override
                            public Observable<DeleteResponse> call(ByteBuf byteBuf) {
                                return DeleteResponse.parse(byteBuf);
                            }
                        });
                    }
                })
                .single()
                .subscribe(new ListenerCompleterObserver<>(listener));
    } catch (Exception e) {
        listener.onFailure(e);
    }
}
 
開發者ID:obourgain,項目名稱:elasticsearch-http,代碼行數:38,代碼來源:DeleteActionHandler.java


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