Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Does _update_by_query work with more than the 10,000 default limit?

I am trying to add a new field (Value) to +10,000 entries stored on ElasticSearch, I came up with a query as follows:

POST index/_update_by_query
{ 
  "query": {
    "bool": {
        "must_not": {
            "exists": {
                "field": "Value"
            }
        }
    }
  },
  "script" : {
      "inline": "ctx._source.Value = 420;"
  }
}

AFAIK, when retrieving a high number of documents, we need to handle pagination by scrolling/PIT, does the same principle apply on _update_by_query?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

No, you don’t need to. The update by query endpoint does this for you in the background. It will scroll over all documents that match the query and update them according to your script and/or your pipeline.

Once a batch of documents has been updated, it fetches the next batch using the scroll API. So you don’t need to care about it, even if you’re about to update millions of documents.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading