{
"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
}
}
multi_match Query
The multi_match query provides a convenient shorthand way of running
the same query against multiple fields.
|
Note
|
There are several types of |
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
could be rewritten more concisely with multi_match as follows:
{
"multi_match": {
"query": "Quick brown fox",
"type": "best_fields", (1)
"fields": [ "title", "body" ],
"tie_breaker": 0.3,
"minimum_should_match": "30%" (2)
}
}
-
The
best_fieldstype is the default and can be left out. -
Parameters like
minimum_should_matchoroperatorare passed through to the generatedmatchqueries.
Using Wildcards in Field Names
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 Fields
Individual fields can be boosted by using the caret (^) syntax: just add
^boost after the field name, where boost is a floating-point number:
{
"multi_match": {
"query": "Quick brown fox",
"fields": [ "*_title", "chapter_title^2" ] (1)
}
}
-
The
chapter_titlefield has aboostof2, while thebook_titleandsection_titlefields have a default boost of1.