[英]How to get only failed documents in the response from Elasticsearch Java High-Level Client 6.8
Is there any way to get only failed documents in the response while bulk request using Elasticsearch Java High-Level REST Client.在使用 Elasticsearch Java 高级 REST 客户端进行批量请求时,有什么方法可以在响应中仅获取失败的文档。
Currently, ES is sending all the succeed and failed document in the response and we are reprocessing all the failed document, we are iterating BulkItemResponse
to find the failed document and reprocessing it.目前,ES 正在响应中发送所有成功和失败的文档,我们正在重新处理所有失败的文档,我们正在迭代
BulkItemResponse
以找到失败的文档并重新处理它。
private BulkRequest createBulkRequestsForRetry(BulkResponse bulkItemResponses, BulkRequest currentBulkRequest) {
BulkRequest bulkRequest = new BulkRequest();
int index = 0;
for (BulkItemResponse bulkItemResponse : bulkItemResponses.getItems()) {
if (bulkItemResponse.isFailed()) {
bulkRequest.add(currentBulkRequest.requests().get(index));
}
index++;
}
return bulkRequest;
}
As bulkItemResponse.getItems()
representing each action performed in the bulk operation (in the same order.).作为
bulkItemResponse.getItems()
表示在批量操作中执行的每个操作(以相同的顺序)。
As of now even in the latest 7.7 version of the client, this feature is not present, if you want this feature you can create an issue or better submit a PR addressing the issue, it would be a very useful feature to have.到目前为止,即使在最新的 7.7 版本的客户端中,此功能也不存在,如果您想要此功能,您可以创建问题或更好地提交 PR 来解决问题,这将是一个非常有用的功能。
You can have a look at the complete BulkResponse and see yourself there is no such functionality present in the master branch as well.您可以查看完整的 BulkResponse并了解自己在 master 分支中也没有此类功能。
Also here you can create an issue to Elasticsearch.此外,您可以在此处向 Elasticsearch 创建问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.