Elasticsearch Multi Match Query – Basic

In previous post, we had known some different types of queries. This tutorial shows some simple ways to use Multi Match Query and several types of them.

Related Posts:
Elasticsearch Overview
ElasticSearch – Structure of a Search Request/Response
ElasticSearch Filter vs Query
ElasticSearch Full Text Queries – Basic

More Practice: Elasticsearch Multi Match Query – More Practice

1. Multi Match Query

multi_match query allows us to search for a value across multiple fields.
For example, we want to search for a string across both “title” and “tags”:

Response:

2. Boosting

– With wildcards:

– Individual fields: using caret (^) notation

Now, we can see that _score has changed:

3. Types of Multi Match query
3.1 Best Fields

best_fields is default type parameter. It uses the _score from the best field.

This type is most useful when we search for multiple words best found in the same field.
For example, “spring integration” in “title” field is more meaningful than in “tags” field, or “spring” in one field and “integration” in the other:

The response:

If we add a tie_breaker, then it calculates the _score:

score [best matching field] + tie_breaker * score [for all other matching fields]

By default, tie_breaker value is 0.
Now we set tie_breaker:

The response has changed:

The _score for document with _id = 5 didn’t change (0.25316024).

3.2 Most Fields

most_fields type is most useful when querying multiple fields that contain the same text analyzed in different ways.

By combining scores from all these 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.

For example:

Response:

3.3 Phrase

phrase and phrase_prefix types behave like best_fields, but they use a match_phrase or match_phrase_prefix query instead of a match query:

3.4 Crosss Fields

You can find it at: Elasticsearch Multi Match Query – More Practice

By JavaSampleApproach | October 30, 2017.

Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*