Hello,
This question relates to the order of execute of filters and queries.
I have two types of search criterion:
- A "terms" query with a few hundred terms. <------- (this is obviously
a very expensive query) - A "geo_bounding_box" filter. <------------------------(this should be
fast and greatly reduce the result set)
Ideally, I would like to, first, use the "geo_bounding_box" filter to
reduce the result set, and then query the filtered documents with the
"terms" query.
Unfortunately, the search time does not appear to be affected by the size
of the geographic boundary (i.e., the number of documents that match the
filter). This makes me believe that it is executing the "terms" filter on
the entire index before filtering.
I've tried the following different queries:
Query #1 (average search time: 2.2s)
{
'query' : {
'terms' : { 'text' : [...]}
},
'filter' : {
'geo_bounding_box' : { ... }
}
}
From what I have read, a filter will execute before a query if it is
nested in a 'filtered' query (sourcehttps://groups.google.com/forum/#!searchin/elasticsearch/filter$20query$20execution$20order/elasticsearch/aL9fzeyTBKE/8vVKuJaNvWUJ).
However, in my case, the average search time for Query #2 actually *doubles
*for some reason:
Query #2 (average search time: 4.4s)
{
'query' : {
'filtered' : {
'query' : {
'terms' : { 'text' : [...]}
},
'filter' : {
'geo_bounding_box' : { ... }
}
}
}
}
Any suggestions are appreciated on how I might execute the fast filter
before the expensive terms query. Thank you!
Shawn
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/25520ad2-68c8-4f26-81fc-75cdf2430d77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.