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

How to increase the max_result_window in elasticsearch using a python script?

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

curl -XPUT "http://localhost:9200/index1/_settings" -d '{ "index" : { "max_result_window" : 500000} }'

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

我的代码

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

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

我的问题是如何在此处更改 max_result_window 的设置

您需要使用put_settings方法。

es.indices.put_settings(index="index1",
                        body= {"index" : {
                                "max_result_window" : 500000
                              }})

万一有人在搜索 ElasticSearch Ruby solution,对我有用的 ES 版本 5 是:

es.indices.put_settings(body: {index: {max_result_window: 500000}})