ES更改参数max_result_window
今天开发那边说翻页超过10000报错。早上来查阅官网手册,说from/size默认是10000。通过参数index.max_result_window进行控制。那么直接改这个参数即可。
1、先看看默认配置
curl -XGET 10.46.2.100:9200/carnoc_jobapply/_settings
{ "carnoc_jobapply": { "settings": { "index": { "number_of_shards": "1", "provided_name": "carnoc_jobapply", "creation_date": "1554089572018", "analysis": { "ik": { "tokenizer": "ik_max_word" } }, "number_of_replicas": "1", "uuid": "ccF77NAHTfiec5-ugvZPfA", "version": { "created": "6010299" } } } } }
没有具体的值,采用的是默认的参数值10000。
2、进行更改参数
curl -XPUT 10.46.2.100:9200/carnoc_jobapply/_settings -d '{ "index.max_result_window" :"500000"}'
抛了个异常
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
这是由于从ES6.0开始需要指定header头,重新编辑下
curl -H "Content-Type: application/json" -XPUT 10.46.2.100:9200/carnoc_jobapply/_settings -d '{ "index.max_result_window" :"500000"}'
返回结果
{"acknowledged":true}
3、再次查看参数值
curl -XGET 10.46.2.100:9200/carnoc_jobapply/_settings
返回
{ "carnoc_jobapply": { "settings": { "index": { "number_of_shards": "1", "provided_name": "carnoc_jobapply", "max_result_window": "500000", "creation_date": "1554089572018", "analysis": { "ik": { "tokenizer": "ik_max_word" } }, "number_of_replicas": "1", "uuid": "ccF77NAHTfiec5-ugvZPfA", "version": { "created": "6010299" } } } } }
修改成功
注意:
1、此方法是设置单索引,如果需要更改索引需要将carnoc_jobapply换成_all
2、即使换成_all,对于新增的索引,还是默认的10000
附上参考文件:
https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html