A newer version is available. For the latest information, see the
current release documentation.
Combined Fields Usageedit
The combined_fields
query supports searching multiple text fields as if their contents had been indexed into one combined field. It takes a
term-centric view of the query: first it analyzes the query string into individual terms, then looks for each term in any of the fields.
See the Elasticsearch documentation on combined fields query for more details.
Fluent DSL exampleedit
q .CombinedFields(c => c .Fields(f => f.Field(p => p.Description).Field("myOtherField")) .Query("hello world") .Boost(1.1) .Operator(Operator.Or) .MinimumShouldMatch("2") .ZeroTermsQuery(ZeroTermsQuery.All) .Name("combined_fields") .AutoGenerateSynonymsPhraseQuery(false) )
Object Initializer syntax exampleedit
new CombinedFieldsQuery { Fields = Field<Project>(p => p.Description).And("myOtherField"), Query = "hello world", Boost = 1.1, Operator = Operator.Or, MinimumShouldMatch = "2", ZeroTermsQuery = ZeroTermsQuery.All, Name = "combined_fields", AutoGenerateSynonymsPhraseQuery = false }
Example json output.
{ "combined_fields": { "_name": "combined_fields", "boost": 1.1, "query": "hello world", "minimum_should_match": "2", "operator": "or", "fields": [ "description", "myOtherField" ], "zero_terms_query": "all", "auto_generate_synonyms_phrase_query": false } }
Combined fields with boost usageedit
Fluent DSL exampleedit
q .CombinedFields(c => c .Fields(Field<Project>(p => p.Description, 2.2).And("myOtherField^1.2")) .Query("hello world") )
Object Initializer syntax exampleedit
new CombinedFieldsQuery { Fields = Field<Project>(p => p.Description, 2.2).And("myOtherField^1.2"), Query = "hello world", }
Example json output.
{ "combined_fields": { "query": "hello world", "fields": [ "description^2.2", "myOtherField^1.2" ] } }