Bird
0
0

What will be the effect of this bool query?

medium📝 Predict Output Q5 of 15
Elasticsearch - Basic Search Queries
What will be the effect of this bool query?
{"bool": {"filter": [{"term": {"brand": "nike"}}], "should": [{"term": {"color": "red"}}, {"term": {"color": "blue"}}], "minimum_should_match": 1}}
ADocuments with brand 'nike' and color 'red' and 'blue' are matched
BDocuments with brand 'nike' only are matched
CDocuments with color 'red' or 'blue' only are matched
DDocuments with brand 'nike' and color 'red' or 'blue' are matched
Step-by-Step Solution
Solution:
  1. Step 1: Understand filter clause

    The filter clause restricts results to documents with brand equal to "nike" without affecting score.
  2. Step 2: Understand should clause with minimum_should_match

    The should clause requires at least one of the colors "red" or "blue" to be matched.
  3. Final Answer:

    Documents with brand 'nike' and color 'red' or 'blue' are matched -> Option D
  4. Quick Check:

    Filter + should with minimum_should_match = combined match [OK]
Quick Trick: filter restricts, should boosts with minimum_should_match [OK]
Common Mistakes:
MISTAKES
  • Ignoring minimum_should_match
  • Assuming should is optional without minimum_should_match

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes