WARNING: The 2.x versions of Elasticsearch have passed their EOL dates. If you are running a 2.x version, we strongly advise you to upgrade.
This documentation is no longer maintained and may be removed. For the latest information, see the current Elasticsearch documentation.
multi_match Queryedit
The multi_match
query provides a convenient shorthand way of running
the same query against multiple fields.
There are several types of multi_match
query, three of which just
happen to coincide with the three scenarios that we listed in
Know Your Data: best_fields
, most_fields
, and cross_fields
.
By default, this query runs as type best_fields
, which means that it generates a
match
query for each field and wraps them in a dis_max
query. This
dis_max
query
{ "dis_max": { "queries": [ { "match": { "title": { "query": "Quick brown fox", "minimum_should_match": "30%" } } }, { "match": { "body": { "query": "Quick brown fox", "minimum_should_match": "30%" } } }, ], "tie_breaker": 0.3 } }
could be rewritten more concisely with multi_match
as follows:
{ "multi_match": { "query": "Quick brown fox", "type": "best_fields", "fields": [ "title", "body" ], "tie_breaker": 0.3, "minimum_should_match": "30%" } }
The |
|
Parameters like |
Using Wildcards in Field Namesedit
Field names can be specified with wildcards: any field that matches the
wildcard pattern will be included in the search. You could match on the
book_title
, chapter_title
, and section_title
fields, with the following:
{ "multi_match": { "query": "Quick brown fox", "fields": "*_title" } }
Boosting Individual Fieldsedit
Individual fields can be boosted by using the caret (^
) syntax: just add
^boost
after the field name, where boost
is a floating-point number: