WARNING: Version 1.6 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Query Filter
editQuery Filter
editWraps any query to be used as a filter. Can be placed within queries that accept a filter.
{ "constantScore" : { "filter" : { "query" : { "query_string" : { "query" : "this AND that OR thus" } } } } }
Keep in mind that once you wrap a query as a filter, it loses query features like highlighting and scoring because these are not features supported by filters.
Caching
editThe result of the filter is not cached by default. The _cache
can be
set to true
to cache the result of the filter. This is handy when
the same query is used on several (many) other queries. Note, the
process of caching the first execution is higher when not caching (since
it needs to satisfy different queries).
Setting the _cache
element requires a different format for the
query
:
{ "constantScore" : { "filter" : { "fquery" : { "query" : { "query_string" : { "query" : "this AND that OR thus" } }, "_cache" : true } } } }