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.
Terms Query Usage
editTerms Query Usage
editFilters documents that have fields that match any of the provided terms (not analyzed).
Be sure to read the Elasticsearch documentation on Terms query for more information.
Fluent DSL example
editq .Terms(c => c .Name("named_query") .Boost(1.1) .Field(p => p.Description) .DisableCoord() .MinimumShouldMatch(MinimumShouldMatch.Fixed(2)) .Terms("term1", "term2") )
Object Initializer syntax example
editnew TermsQuery { Name = "named_query", Boost = 1.1, Field = "description", Terms = ExpectedTerms, DisableCoord = true, MinimumShouldMatch = 2 }
Example json output.
{ "terms": { "_name": "named_query", "boost": 1.1, "description": [ "term1", "term2" ], "disable_coord": true, "minimum_should_match": 2 } }
Single term Terms Query
editFluent DSL example
editq .Terms(c => c .Name("named_query") .Boost(1.1) .Field(p => p.Description) .DisableCoord() .MinimumShouldMatch(MinimumShouldMatch.Fixed(2)) .Terms("term1") )
Verbatim terms query
editBy default an empty terms array is conditionless so will be rewritten. Sometimes sending an empty an empty array to mean
match nothing makes sense. You can either use the ConditionlessQuery
construct from NEST to provide a fallback or make the
query verbatim as followed:
Object Initializer syntax example
editnew TermsQuery { IsVerbatim = true, Field = "description", Terms = new string[] {}, }
Example json output.
{ "terms": { "description": [] } }
Fluent DSL example
editq .Terms(c => c .Verbatim() .Field(p => p.Description) .Terms(new string[] {}) )