欢迎来到我的的博客园,祝大家学有所成,早点实现自己的人生理想。

使用elasticsearch分页时报max_result_window is too large的错误解决方案

使用elasticsearch进行深度分页查询时的size-from大于10000的时候,会提示一个max_result_window is too large的错误。

 

官方推荐是scroll查询返回结果是无序的不满足业务需求,所以还是通过设置最大返回结果数来达到我们的目的

然后我们可以通过以下方法设置:node settings must not contain any index level settings

第一种:

curl -H "Content-Type: application/json" -XPUT 'http://127.0.0.1:9200/_all/_settings?preserve_existing=true' -d '{
  "index.max_result_window" : "1000000000"
}'

或者

curl -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/_settings -d '{ "index" : { "max_result_window" : 100000000}}'

 

第二种:在config/elasticsearch.yml文件中的最后加上index.max_result_window: 100000000,但是这种方法要注意在最前面加上空格

 

但是要注意,5.x之后,已经不支持第二种方式了。否则启动时,会报下列错误:

 

posted @ 2019-01-03 17:34  宋兴柱  阅读(3476)  评论(0编辑  收藏  举报