如何使用python脚本增加elasticsearch中的max_result_窗口?

2024-04-28 11:24:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道,我们可以使用旋度来增加max_result_窗口,如下所示:

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
}})

我的问题是,如何更改此处“最大结果”窗口的设置


Tags: 代码localhosthttpindexsettingsesresultcurl
2条回答

您需要使用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}})

相关问题 更多 >