Update by query with index alias

In the Alias documentation it says that write operations aren't allowed on index alias and that it would return an error:

If an alias points to multiple indices or data streams and is_write_index isn’t set, the alias rejects write requests.

However in the update by query documentation it says:

(Optional, string) Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (*). To search all data streams or indices, omit this parameter or use * or _all.

Failure may be true for example for updating a single doc by id, but an _update_by_query succeeds when run on an index alias.

So am I missing anything or is the Alias documentation not accurate?

It is correct as update by query first runs a query to identify which documents are to be updated (and indices these are located in) before updating these directly using the appropriate index, not the alias.

I see, but it's a bit misleading, since as far as the end user, both of these are considered write operations using an alias:
POST alias/_update/5
POST alias/_update_by_query

The way that Elasticsearch handles it behind the scene may be different as you say, but the Alias docs saying that using the alias for write operations will fail as a whole is misleading, and I think that part needs to be revised.

You'd be best off raising an issue on GitHub to have it addressed :slight_smile:

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