I tried to do some queries to alias with multiple indices in Kibana with profiler and it seems that when you make high-level filter on _index field - it runs some really fast MatchNoDocQuery queries on all indices except the needed one.
E.g.: let's say we have two indices: test.book and test.film. We have an alias test with pattern test.*. Also each index has product_type field which may be "book" or "film".
It seems that this query:
GET test/_search
{
"query": {
"bool": {
"filter": [
{
"terms": {
"_index": ["test.film"]
}
}
]
}
}
Is much faster than this query:
GET test/_search
{
"query": {
"bool": {
"filter": [
{
"terms": {
"product_type": ["film"]
}
}
]
}
}
}
Are there any optimizations when running filter on "_index" field?