首页 > 解决方案 > The RestHighLevelClient cannot be used with elasticsearch 7 BulkProcessor. Which client should be used?

问题描述

The elasticsearch 7 documentation - https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-bulk-processor.html

mentions the client to be used as follows- https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/client.html

Here HightLevelRest Client cannot be used with bulkprocessor in elastisearch7.

This is different from what they had suggested in elasticsearch 6 - https://www.elastic.co/guide/en/elasticsearch/client/java-api/6.4/client.html

Could someone mention which client they use with bulkprocessor in elasticsearch 7

标签: elasticsearch

解决方案


RestHighLevelClient 可以与 ElasticSearch7 BulkProcessor 一起使用。你应该看看源代码。唯一的变化是 RestHighLevelClient bulkAsycn 方法。它现在需要一个额外的参数 RequestOptions。所以以前的签名是 -

BulkProcessor.builder(restHighLevelClient()::bulkAsync, listener);

新签名如下:

BulkProcessor.builder((request, bulkListener) -> restHighLevelClient.bulkAsync(request, RequestOptions.DEFAULT, bulkListener), bulkProcessorListener
            );

希望能帮助到你


推荐阅读