Can someone tell me the difference between
"query": {
"bool": {
"should": [
{ "match": {"title": keyword} },
{ "match": {"description": keyword} }
]
}
and
"query": {
"multi_match": {
"query": keyword,
"fields": [ "title", "description" ]
}
}
Is there any performance turning if choose one of two above?
Types of multi_match query:edit (default) Finds documents which match any field, but uses the _score from the best field. See best_fields . Finds documents which match any field and combines the _score from each field. See most_fields .
must means: Clauses that must match for the document to be included. should means: If these clauses match, they increase the _score ; otherwise, they have no effect. They are simply used to refine the relevance score for each document. Yes you can use multiple filters inside must .
One of the most common queries in elasticsearch is the match query, which works on a single field. And there's another query with the very same options that works also on multiple fields, called multi_match. These queries support text analysis and work really well.
The multi_match query builds on the match query to allow multi-field queries: GET /_search { "query": { "multi_match" : { "query": "this is a test", "fields": [ "subject", "message" ] } } } The query string. The fields to be queried.
It depends on the type parameter of your multi_match
. In your example, since you didn't specify a type, best_fields is used. That makes use of a Dis Max Query and basically
uses the _score from the best field
On the other hand, your example with should
combines the _score from each field.
and it is equivalent to multi_match
with type most_fields
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With