简体   繁体   English

如何在来自 Elasticsearch Java 高级客户端 6.8 的响应中仅获取失败的文档

[英]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.

相关问题 ElasticSearch 多词查询与 Java 高级 REST 客户端 - ElasticSearch Multi Term Query With Java High-Level REST Client Elasticsearch 高层 REST 客户端连接失败 https - Elasticsearch high-level REST client fails to connect over https 如何使用ElasticSearch rest高级客户端按任意字段中的任何单词进行搜索? - How to search by any word in any field with ElasticSearch rest high-level client? ElasticSearch Java 高级 REST 客户端:过滤文档和或查询 - ElasticSearch Java High Level REST Client: filter documents and or query Elasticsearch Java High-Level REST Client 建立一堆TCP连接,索引数据后不关闭 - Elasticsearch Java High-Level REST Client establish a bunch of TCP connection and doesn't close them after indexing data 如何使用 java 高级别 rest3A84DEFA4886DAFCE6A4E7AE63A3BAEED443C48Z 在 elasticsearch 中知道是成功还是失败 - How to know if a reindex from remote task is sucessful or failed in elasticsearch using the java high level rest API 在 Java 的 elasticsearch 高级客户端中添加身份验证 - Add authentication in elasticsearch high level client for Java 通过高级客户端写入Elasticsearch-在文档上设置时间戳 - Writing to elasticsearch via high level client - setting timestamp on documents 使用 Elasticsearch 的 Java High Level Rest Client 收到对异步请求的响应后立即返回某些内容 - return something as soon as a response to an async request is received using Elasticsearch's Java High Level Rest Client Elasticsearch Java 高级客户端 7.3.1:搜索响应中索引明智命中的聚合 - Elasticsearch Java High Level Client 7.3.1 :Aggregation for Index wise hits in search Response
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM