A query that applies a filter to the results of another query.
How I interpret that statement is that the query will run first then the
filter will be applied. Can this behavior be adjusted?
Also, I can execute a search with an independent filter and query which
produces the same results as a filtered query. It appears the timing is
about the same as well.
Can I simply place the filter first within the JSON object then the
query to control whether the filter is run before the query?
Ultimately, I just really want to know the behavior for when filters are
run before queries and if there is a possibility to control the execution
precedence.
Thank you!
--
Coyote Logistics, LLC is a licensed Property Broker (MC# 561135-B).
Basically the filter in a filtered query is executed before the query. IMHO
that documentation is misleading. Use post filters (simply 'filter' before
1.0) to execute the filters after the query.
A query that applies a filter to the results of another query.
How I interpret that statement is that the query will run first then the
filter will be applied. Can this behavior be adjusted?
Also, I can execute a search with an independent filter and query which
produces the same results as a filtered query. It appears the timing is
about the same as well.
Can I simply place the filter first within the JSON object then the
query to control whether the filter is run before the query?
Ultimately, I just really want to know the behavior for when filters are
run before queries and if there is a possibility to control the execution
precedence.
The documentation suddenly made me doubt if we I knew was wrong.
The default strategy for Elasticsearch's filtered query is a custom random
access one. For each document, it will first check the docSet before
executing the query.
Basically the filter in a filtered query is executed before the query.
IMHO that documentation is misleading. Use post filters (simply 'filter'
before 1.0) to execute the filters after the query.
A query that applies a filter to the results of another query.
How I interpret that statement is that the query will run first then the
filter will be applied. Can this behavior be adjusted?
Also, I can execute a search with an independent filter and query which
produces the same results as a filtered query. It appears the timing is
about the same as well.
Can I simply place the filter first within the JSON object then the
query to control whether the filter is run before the query?
Ultimately, I just really want to know the behavior for when filters are
run before queries and if there is a possibility to control the execution
precedence.
I guess I'll stick with the default strategy for now due to inexperience
and lack of experimentation. I assume it should provide generally good
performance.
As I learn more I might try to mess with strategy and hopefully a filter
first strategy gets implemented. I would assume this would greatly
increase string based queries by filtering to a subset of documents first!
On Tuesday, February 18, 2014 3:19:50 PM UTC-6, Ivan Brusic wrote:
The documentation suddenly made me doubt if we I knew was wrong.
The default strategy for Elasticsearch's filtered query is a custom random
access one. For each document, it will first check the docSet before
executing the query.
The strategy is configurable, so it would be nice to be added to the
documentation. The original description of the filtered query comes
directly from Lucene: FilteredQuery (Lucene 4.6.0 API)
Cheers,
Ivan
On Tue, Feb 18, 2014 at 1:02 PM, Ivan Brusic <iv...@brusic.com<javascript:>
Basically the filter in a filtered query is executed before the query.
IMHO that documentation is misleading. Use post filters (simply 'filter'
before 1.0) to execute the filters after the query.
--
Ivan
On Tue, Feb 18, 2014 at 12:42 PM, Ivan Hall <ivan...@coyote.com<javascript:>
wrote:
I am brand new to Elasticsearch and have a few fundamental questions
regarding queries and filters.
How does one control ordering of filter vs query? Is it possible
to filter first, then perform a query on those results?
A query that applies a filter to the results of another query.
How I interpret that statement is that the query will run first then the
filter will be applied. Can this behavior be adjusted?
Also, I can execute a search with an independent filter and query which
produces the same results as a filtered query. It appears the timing is
about the same as well.
Can I simply place the filter first within the JSON object then the
query to control whether the filter is run before the query?
Ultimately, I just really want to know the behavior for when filters are
run before queries and if there is a possibility to control the execution
precedence.
I guess I'll stick with the default strategy for now due to inexperience
and lack of experimentation. I assume it should provide generally good
performance.
As I learn more I might try to mess with strategy and hopefully a filter
first strategy gets implemented. I would assume this would greatly
increase string based queries by filtering to a subset of documents first!
On Tuesday, February 18, 2014 3:19:50 PM UTC-6, Ivan Brusic wrote:
The documentation suddenly made me doubt if we I knew was wrong.
The default strategy for Elasticsearch's filtered query is a custom
random access one. For each document, it will first check the docSet before
executing the query.
The strategy is configurable, so it would be nice to be added to the
documentation. The original description of the filtered query comes
directly from Lucene: FilteredQuery (Lucene 4.6.0 API)
Cheers,
Ivan
On Tue, Feb 18, 2014 at 1:02 PM, Ivan Brusic iv...@brusic.com wrote:
Basically the filter in a filtered query is executed before the query.
IMHO that documentation is misleading. Use post filters (simply 'filter'
before 1.0) to execute the filters after the query.
A query that applies a filter to the results of another query.
How I interpret that statement is that the query will run first then
the filter will be applied. Can this behavior be adjusted?
Also, I can execute a search with an independent filter and query which
produces the same results as a filtered query. It appears the timing is
about the same as well.
Can I simply place the filter first within the JSON object then
the query to control whether the filter is run before the query?
Ultimately, I just really want to know the behavior for when filters
are run before queries and if there is a possibility to control the
execution precedence.
Other than what Ivan Brusic already explained, there is also a difference
in how the facets/aggregations are computed. In your first example, the
aggregations are computed based on the results that match only the query
part. In your second example, the aggregations are computed based on the
results from both the query + filter.
If you trace the code more, you would see that it eventually uses
Lucene's LEAP_FROG_FILTER_FIRST_STRATEGY which according to the docs:
"Note: This strategy uses the filter to lead the iteration.". This strategy
is used when the default threshold (-1) is set and the DocIdSet (basically
bits) is "fast" (aka nothing expense like geo).
Binh answered your other question. Basically the outer filter is now called
post_filter to remove the ambiguity.
I guess I'll stick with the default strategy for now due to inexperience
and lack of experimentation. I assume it should provide generally good
performance.
As I learn more I might try to mess with strategy and hopefully a filter
first strategy gets implemented. I would assume this would greatly
increase string based queries by filtering to a subset of documents first!
On Tuesday, February 18, 2014 3:19:50 PM UTC-6, Ivan Brusic wrote:
The documentation suddenly made me doubt if we I knew was wrong.
The default strategy for Elasticsearch's filtered query is a custom
random access one. For each document, it will first check the docSet before
executing the query.
The strategy is configurable, so it would be nice to be added to the
documentation. The original description of the filtered query comes
directly from Lucene: Index of /__root/docs.lucene.apache.org/core/4_6_0/core/org
apache/lucene/search/FilteredQuery.html
Cheers,
Ivan
On Tue, Feb 18, 2014 at 1:02 PM, Ivan Brusic iv...@brusic.com wrote:
Basically the filter in a filtered query is executed before the query.
IMHO that documentation is misleading. Use post filters (simply 'filter'
before 1.0) to execute the filters after the query.
A query that applies a filter to the results of another query.
How I interpret that statement is that the query will run first then
the filter will be applied. Can this behavior be adjusted?
Also, I can execute a search with an independent filter and query which
produces the same results as a filtered query. It appears the timing is
about the same as well.
Can I simply place the filter first within the JSON object then
the query to control whether the filter is run before the query?
Ultimately, I just really want to know the behavior for when filters
are run before queries and if there is a possibility to control the
execution precedence.
--
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 elasticsearc...@googlegroups.com.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.