本文整理汇总了Java中org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse类的典型用法代码示例。如果您正苦于以下问题:Java IndexDeleteByQueryResponse类的具体用法?Java IndexDeleteByQueryResponse怎么用?Java IndexDeleteByQueryResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexDeleteByQueryResponse类属于org.elasticsearch.action.deletebyquery包,在下文中一共展示了IndexDeleteByQueryResponse类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildDelete
import org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse; //导入依赖的package包/类
public void buildDelete(XContentBuilder builder,
DeleteByQueryResponse response) throws IOException {
builder.startObject();
builder.startObject("_indices");
for (IndexDeleteByQueryResponse indexDeleteByQueryResponse : response
.getIndices().values()) {
builder.startObject(indexDeleteByQueryResponse.getIndex(),
XContentBuilder.FieldCaseConversion.NONE);
builder.startObject("_shards");
builder.field("total", indexDeleteByQueryResponse.getTotalShards());
builder.field("successful",
indexDeleteByQueryResponse.getSuccessfulShards());
builder.field("failed",
indexDeleteByQueryResponse.getFailedShards());
builder.endObject();
builder.endObject();
}
builder.endObject();
builder.endObject();
}
示例2: toXContent
import org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse; //导入依赖的package包/类
@Override
protected XContentBuilder toXContent(DeleteByQueryRequest request, DeleteByQueryResponse response, XContentBuilder builder) throws IOException {
builder.startObject().field(Fields.OK, true);
builder.startObject("_indices");
for (IndexDeleteByQueryResponse indexDeleteByQueryResponse : response.getIndices().values()) {
builder.startObject(indexDeleteByQueryResponse.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
builder.startObject("_shards");
builder.field("total", indexDeleteByQueryResponse.getTotalShards());
builder.field("successful", indexDeleteByQueryResponse.getSuccessfulShards());
builder.field("failed", indexDeleteByQueryResponse.getFailedShards());
builder.endObject();
builder.endObject();
}
builder.endObject();
builder.endObject();
return builder;
}
示例3: buildResponse
import org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse; //导入依赖的package包/类
@Override
public RestResponse buildResponse(DeleteByQueryResponse result, XContentBuilder builder) throws Exception {
RestStatus restStatus = result.status();
builder.startObject();
builder.startObject(Fields._INDICES);
for (IndexDeleteByQueryResponse indexDeleteByQueryResponse : result.getIndices().values()) {
builder.startObject(indexDeleteByQueryResponse.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
builder.startObject(Fields._SHARDS);
builder.field(Fields.TOTAL, indexDeleteByQueryResponse.getTotalShards());
builder.field(Fields.SUCCESSFUL, indexDeleteByQueryResponse.getSuccessfulShards());
builder.field(Fields.FAILED, indexDeleteByQueryResponse.getFailedShards());
ShardOperationFailedException[] failures = indexDeleteByQueryResponse.getFailures();
if (failures != null && failures.length > 0) {
builder.startArray(Fields.FAILURES);
for (ShardOperationFailedException shardFailure : failures) {
builder.startObject();
builder.field(Fields.INDEX, shardFailure.index());
builder.field(Fields.SHARD, shardFailure.shardId());
builder.field(Fields.REASON, shardFailure.reason());
builder.endObject();
}
builder.endArray();
}
builder.endObject();
builder.endObject();
}
builder.endObject();
builder.endObject();
return new BytesRestResponse(restStatus, builder);
}
示例4: checkForFailures
import org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse; //导入依赖的package包/类
private void checkForFailures(String name, DeleteByQueryResponse actionGet) {
for (IndexDeleteByQueryResponse r : actionGet) {
if (r.getFailedShards() > 0) {
LOG.error("SuccessfulShards {} / {} for {}",
r.getSuccessfulShards(), r.getTotalShards(), name);
}
}
}
示例5: checkDeleteByQueryResponse
import org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse; //导入依赖的package包/类
/**
* Validate the response doesn't contain errors, if it does, fail fast at the first error we encounter
*/
private void checkDeleteByQueryResponse( final QueryBuilder query, final DeleteByQueryResponse response ) {
for ( IndexDeleteByQueryResponse indexDeleteByQueryResponse : response ) {
final ShardOperationFailedException[] failures = indexDeleteByQueryResponse.getFailures();
for ( ShardOperationFailedException failedException : failures ) {
logger.error("Unable to delete by query {}. Failed with code {} and reason {} on shard {} in index {}",
query.toString(),
failedException.status().getStatus(), failedException.reason(),
failedException.shardId(), failedException.index() );
}
}
}
示例6: truncateIndex
import org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse; //导入依赖的package包/类
public IndexDeleteByQueryResponse truncateIndex() throws InterruptedException, ExecutionException {
try (Client client = getClient()) {
QueryBuilder queryBuilder = new MatchAllQueryBuilder();
ListenableActionFuture<DeleteByQueryResponse> response = client.prepareDeleteByQuery(INDEX_NAME)
.setTypes(DOCUMENT_TYPE).setQuery(queryBuilder).execute();
DeleteByQueryResponse deleteByQueryResponse = response.get();
IndexDeleteByQueryResponse indexResult = deleteByQueryResponse.getIndex(INDEX_NAME);
return indexResult;
}
}