elena
elena

Reputation: 4178

ElasticSearch "multi_match" and "minimum_should_match"

I have a very strange case and I cannot understand why this happens. This is part of the query.

      "must": [
        {
          "multi_match": {
            "query": "makkara",
            "type": "best_fields",
            "fields": ["text.general", "text.fi"],
            "minimum_should_match": 10
          }
        }
      ]

text.general field is a trigrams field, meaning it's analyzed with a ngram filter, where max and min gram are 3. Basically, the are five tokens: "mak", "akk", "kka", "kar", "ara". The field "text.fi" is analyzed with Finnish analyzer. I've tried it and it returns "makkar" (pretty stupid, actually).

So the issue is in how this minimum should match works. I don't get its mechanics. As soon as it becomes 5 it returns the same results no matter what I put there. Anything >=5 returns same results. Could someone explain why is it so?

Upvotes: 0

Views: 2172

Answers (1)

Barkha Jain
Barkha Jain

Reputation: 768

As per your question, the number of tokens generated by analyzers of both fields for search term "makkara" is <= 5. So, the minimum_should_match = 5 in this case would mean all search terms must be present.

And hence, any minimum_should_match value greater than 5 will still mean all the 5 terms must be present. This is why you don't see change in results for values greater than 5.

Upvotes: 0

Related Questions