Description
While trying to remove indicesQuery (deprecated by #17710) in my own code base, I noticed the following problem: The indicesQuery supports to pass any name of an index to the query, so also aliases work (of course it does not work with filtered aliases, doesn't it? - but that does not matter for the problem).
In my case I needed a query that returns results of a query for a specific index only (only alias name known, not its real name) and a matchAll query for the other indexes. Setup was:
- alias named "allMyStuff" with 3 indexes. Each of the three indexes have an internal, timestamped name, but there also exists an alias pointing to the most recent index. The client code only knows the alias, not the real index name.
- query executes on "allMyStaff" alias and filters the indices to query using indicesQuery.
This works with indicesQuery, specifiying the alias to only run the specific query on and return matchAll for all the others. With a term query on "_index" field, you cannot use the alias anymore. It only return documents if the index matches completely, so termQuery("_index", "alias") does not match anything.
So I don't agree with deprecating and removing indicesQuery unless this can be fixed.