Hi, i have a simple query that looks like this:
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{ "term": { "a": "term1" }},
{ "term": { "a": "term2" }},
{ "term": { "a": "term3" }},
{ "term": { "a": "term4" }},
{ "term": { "a": "term5" }},
{ "wildcard": { "b": "*a rather*long*expression of*various*words" }}
]
}
}
}
}
}
The query takes about 500 ms to execute on an index with 3 mil documents with 4 even shards on ES 5.3.2.
The query returns no results for these particular terms and wildcard expression, which is fine.
If I remove the wildcard query, the query returns in 2 ms, also with no results (again, this is fine).
I tried placing the wildcard query in different positions inside the bool, to no avail.
I thought that the wildcard filter, combined with the term filters, would execute efficiently, but it looks like the wildcard filter scans the entire index regardless of the term filters.
Is there any way to make this work efficiently?
Thanks,
Roman Margolis