Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I know, we can use the curl to increase the max_result_window as something like:

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

But How do I do the same using python?

My code

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

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

My question is how,do I change the setting for max_result_window here.

like image 777
Mayank Jha Avatar asked Oct 21 '16 19:10

Mayank Jha


People also ask

How do I test Elasticsearch connection in python?

Use cURL and make an XGET request You can check if a cluster in Elasticsearch is running with the integral requests library. Alternatively, you can use a method of Elasticsearch's library low-level client. Try this cURL rquest to check if a cluster in Elasticsearch is active.


2 Answers

You need to use put_settings method.

es.indices.put_settings(index="index1",
                        body= {"index" : {
                                "max_result_window" : 500000
                              }})
like image 199
ChintanShah25 Avatar answered Oct 23 '22 19:10

ChintanShah25


In case somebody is searching for a ElasticSearch Ruby solution, what worked for me on ES version 5 was:

es.indices.put_settings(body: {index: {max_result_window: 500000}})
like image 42
Diogo Publio Avatar answered Oct 23 '22 18:10

Diogo Publio