I want to do an update by query (_update_by_query), and I only want 100 documents to be affected. An analogy in SQL is UPDATE foo SET a = 5 LIMIT 100. Is it possible?
Since 7.3, the _update_by_query API supports the max_docs parameter, which you can use to specify the maximum number of documents to update
POST foo/_update_by_query?max_docs=100
{
  "script": {
    "source": "ctx._source.a = 5"
  }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With