如何使用python脚本增加elasticsearch中的max_result_window?

May*_*Jha 8 python python-2.6 elasticsearch elasticsearch-plugin spring-data-elasticsearch

我知道,我们可以使用curl来增加max_result_window,如:

curl -XPUT "http://localhost:9200/index1/_settings" -d '{ "index" : { "max_result_window" : 500000} }'
Run Code Online (Sandbox Code Playgroud)

但是我如何使用python做同样的事情?

我的代码

es = Elasticsearch(['http://localhost:9200'])

res = es.search(index="index1", doc_type="log",size=10000, from_=0, body={ "query": {
....query starts
}})
Run Code Online (Sandbox Code Playgroud)

我的问题是如何在这里更改max_result_window的设置.

Chi*_*h25 10

你需要使用put_settings方法.

es.indices.put_settings(index="index1",
                        body= {"index" : {
                                "max_result_window" : 500000
                              }})
Run Code Online (Sandbox Code Playgroud)