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

10,986

Solution 1

You need to use put_settings method.

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

Solution 2

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}})
Share:
10,986

Related videos on Youtube

Mayank Jha
Author by

Mayank Jha

Updated on June 04, 2022

Comments

  • Mayank Jha
    Mayank Jha almost 2 years

    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.

  • ChintanShah25
    ChintanShah25 over 7 years
    glad I could help
  • Kushal
    Kushal over 7 years
    Thanks for the help Chintan
  • Kerem
    Kerem almost 6 years
    I'm trying to use this solution but I got an error. Anyone see this comment, could you check quickly my question?