WARNING: Version 5.x 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.
Filtered Query Usageedit
The filtered query is used to combine a query which will be used for scoring with another query which will only be used for filtering the result set.
Deprecated in 2.0.0-beta1. Use the bool query instead with a
must
clause for the query and a filter
clause for the filter.
See the Elasticsearch documentation on filtered query for more details.
Fluent DSL exampleedit
q .Filtered(c => c .Name("named_query") .Boost(1.1) .Filter(qq => qq.MatchAll(m => m.Name("filter"))) .Query(qq => qq.MatchAll(m => m.Name("query"))) )
Object Initializer syntax exampleedit
new FilteredQuery() { Name = "named_query", Boost = 1.1, Filter = new MatchAllQuery { Name ="filter" }, Query = new MatchAllQuery() { Name = "query" }, }
Example json output.
{ "filtered": { "_name": "named_query", "boost": 1.1, "filter": { "match_all": { "_name": "filter" } }, "query": { "match_all": { "_name": "query" } } } }