如何使用Python脚本增加Elasticsearch的max_result_window?

9
我知道,我们可以使用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的设置。

2个回答

16
您需要使用 put_settings 方法。
es.indices.put_settings(index="index1",
                        body= {"index" : {
                                "max_result_window" : 500000
                              }})

很高兴我能帮到你。 - ChintanShah25
1
感谢你的帮助,Chintan。 - Kushal
我正在尝试使用这个解决方案,但是出现了错误。如果有人看到这条评论,请快速检查一下我的问题 - Kerem

1

如果有人正在寻找ElasticSearch Ruby解决方案,在ES 5版本上对我有效的是:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接