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

Time:11-08

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?

CodePudding user response:

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.

  • Related