- Docs
- Cloaked Search
- Usage
- Querying
- Multi-Match
Multi-match Query
The multi_match
query builds on the match query to allow multi-field queries.
Common Parameters
query
(Required, string) The query string to evaluate.
fields
(Required, array of strings) The field names to query over. Fields can be boosted with the caret operator (
^
). Wildcards (*
) are not supported.type
(Optional, string) The way the multi_match query is executed internally depends on the
type
parameter. Defaults tobest_fields
.
multi_match
queries
Types of best_fields
(Default)
The best_fields
type is most useful when you are searching for multiple words best found in the same field. For instance “brown fox” in a single field is more meaningful than “brown” in one field and “fox” in the other.
The best_fields
type generates a match
query for each field and wraps them in a dis_max
query, to find the single best matching field.
best_fields
supports the same parameters as the match query as well as tie_breaker
.
Example
JSON{ "query": { "multi_match" : { "query": "brown fox", "type": "best_fields", "fields": [ "subject", "message" ], "tie_breaker": 0.3 } } }
most_fields
The most_fields
type is most useful when querying multiple fields that contain the same text analyzed in different ways. For instance, the main field may contain synonyms, stemming and terms without diacritics. A second field may contain the original terms, and a third field might contain shingles. By combining scores from all three fields we can match as many documents as possible with the main field, but use the second and third fields to push the most similar results to the top of the list.
most_fields
supports the same parameters as the match query.
Example
JSON{ "query": { "multi_match" : { "query": "quick brown fox", "type": "most_fields", "fields": [ "title", "title.original", "title.shingles" ] } } }
Unsupported
The phrase
, phrase_prefix
, cross_fields
, and bool_prefix
types are not supported at this time.