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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM