本文整理汇总了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");
}
示例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);
}
示例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);
}
}
示例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);
}
}