elasticsearch出现 entity content is too long问题解决
一、现象
项目中使用了[elasticsearch]的Java Low Level REST Client来操作es,低级客户端的特性就是需要手动控制对es的请求,所以会遇到一些请求过程中的问题。比如今天,线上环境在导出数据时es报错,提示 entity content is too long [145648701] for the configured buffer limit。大概意思是返回值过大,超过buffer限制。在导出数据超过5000条时会出现该问题,导出数据较少时不会出现。
二、排查
先看一下低级客户端怎么存储返回值
private final AtomicReference<Response> response = new AtomicReference<>();
HttpAsyncResponseConsumerFactory DEFAULT = new HeapBufferedResponseConsumerFactory(DEFAULT_BUFFER_LIMIT);
static final int DEFAULT_BUFFER_LIMIT = 100 * 1024 * 1024;
可以看到,默认情况下,HeapBufferedResponseConsumerFactory限制的大小是100M。我们找一下能否配置。