场景 做分页查询,当分页达到一定量的时候,报如下错误:
Result window is too large, from + size must be less than or equal to: [10000] but was [78020]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting. 1 原因分析 es对from + size的大小进行限制,必须小于等于10000。
es 默认查询通过from+size 最大是10000,超过1w就需要进行设置
es设置index.max_result_window(就是from+size,默认大小10000),
可通过如下方式修改:
curl -XPUT 192.168.40.31:9200/datasmart/_settings -d ‘{ “index.max_result_window” :”1000000”}’
成功返回:
{“acknowledged”:true} 这个请求只会对datasmart这个索引起作用,如果是设置所有索引,把datasmart改成_all即可
查询当前max_result_window把PUT改成GET,如:
curl -XGET 192.168.40.31:9200/datasmart/_settings
返回:
{ “datasmart”: { “settings”: { “index”: { “number_of_shards”: “3”, “provided_name”: “datasmart”, “max_result_window”: “1000000”, “creation_date”: “1506303097464”, “analysis”: { “analyzer”: { “default”: { “type”: “smartcn” } } }, “number_of_replicas”: “1”, “uuid”: “84ufzn8nQ1-InuxYGHj_IA”, “version”: { “created”: “5050199” } } } } }