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

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 individually, just want to know whether there will be a performance overhead when using _update_by_query for updating single document than getting and update using _update api.

Thanks in Advance.

Update-by-query uses scrolled searches, which in turn use a point in time snapshot of the data - however this won't be held to long in your case as you only update a single document.

I do not have any numbers in this concrete use-case what will save more resources, so it really is hard to tell from my point of view.

About how many updates per time frame are you talking?

1 Like

Thank for the reply @spinscale . Currently we are having 600 updates every minute on average. But the numbers can scale if the consumption scales, which is very likely. Now that you have mentioned, its scrolled search that is behind the scene, also just curious if there is a chance for max_open_scroll_context to exceed max limit which is 500 by default, if we use _update_by_query.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.