Bird
Raised Fist0

Given this Elasticsearch query snippet, what will be the effect of using "minimum_should_match": 2 in a bool query with three should clauses?

medium📝 Predict Output Q13 of Q15
Elasticsearch - Advanced Patterns
Given this Elasticsearch query snippet, what will be the effect of using "minimum_should_match": 2 in a bool query with three should clauses?
{
  "query": {
    "bool": {
      "should": [
        { "match": { "title": "search" } },
        { "match": { "content": "fast" } },
        { "match": { "tags": "elasticsearch" } }
      ],
      "minimum_should_match": 2
    }
  }
}
ADocuments matching any one of the should clauses will be returned.
BDocuments must match at least two of the three should clauses to be returned.
CDocuments must match all three should clauses to be returned.
DThe query will cause a syntax error because minimum_should_match is invalid here.
Step-by-Step Solution
Solution:
  1. Step 1: Understand bool query with should clauses

    Should clauses mean documents matching any are considered, but minimum_should_match controls how many must match.
  2. Step 2: Effect of minimum_should_match = 2

    Setting minimum_should_match to 2 means at least two of the should clauses must match for a document to be returned.
  3. Final Answer:

    Documents must match at least two of the three should clauses to be returned. -> Option B
  4. Quick Check:

    minimum_should_match = 2 means at least two matches [OK]
Quick Trick: minimum_should_match sets how many should clauses must match [OK]
Common Mistakes:
MISTAKES
  • Thinking minimum_should_match means all clauses must match
  • Assuming it causes syntax error
  • Confusing should with must clauses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes