java.io.IOException: entity content is too long [xxx] for the configured buffer limit [1048576]

java 使用 es hight-level-client 连接集群 ,滚动导出数据报错。

 异常原因:response内容太大。buffer装不下了。

解决方式,我的是滚动导出数据,可以调小批量的大小。

但是我不想批量太小,影响处理速度。所以采用方案2,如下:

报错的写法如下

 searchResponse = client.scroll(scrollRequest, RequestOptions.DEFAULT);

解决方案2:自定义一个 requestOptions

     RequestOptions.Builder options = RequestOptions.DEFAULT.toBuilder();
        options.setHttpAsyncResponseConsumerFactory(
                new HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory(4 * 104857600));
        final RequestOptions requestOptions = options.build();
 searchResponse = client.scroll(scrollRequest, requestOptions);

猜你喜欢

转载自blog.csdn.net/star1210644725/article/details/131052349