ElasticSearch查询超过10000条报错Result window is too large

背景

后台查询订单列表,将mysql查询改造为es查询.分页展示,每页10条数据,当查询页数超过1000页时,发现后台es报错,报错信息为:

(’Result window is too large, from + size must be less than or equal to: [10000] but was [10100]. 
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 parameter.’)

分析

分析报错信息,明显提示结果窗口集太大了,条数不应该超过10000条.这是因为ElasticSearch默认查询10000条展示(官网有说明),当超过10000条时,就会报错

解决方式

可以通过elasticsearch-head插件解决

1.关闭索引库

 

 2.点击复合查询

 

 3.执行PUT语法(这里数值修改为足够大)

 

 4.查看返回结果(true代表成功)

 

 5.打开索引库

 

注意:执行PUT语法时可能会报错 :

Content-Type header [application/x-www-form-urlencoded] is not supported

解决方法如下:

修改head插件目录下的vendor.js文件的6886行和7573行

将application/x-www-form-urlencoded 替换为 application/json;charset=UTF-8

再次执行PUT语句即可

posted @ 2020-07-22 10:21  狼_少_年  阅读(1339)  评论(0编辑  收藏  举报