Is Update By Query API a good choice to update single document in elasticsearch?

1.1k Views Asked by At

I have a use case where I want to update the document without knowing its index. Currently I am querying by id and getting the index and then updating (2 operation). Update By Query API seems to perform this use case in single operation. But I am just skeptical because as per the Elasticsearch documentation,

When you submit an update by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and updates matching documents using internal versioning.

As there will be a lot of updates, just want to know whether there will be a performance overhead when using _update_by_query for single document than getting and update using _update API.

1

There are 1 best solutions below

0
On

Internally, the _update_by_query gets translated into a search operation followed by an update, so it can be used. One consideration that you may have to make is that same ids can exist across ElasticSearch indexes.