Bird
0
0

Given this bool query, which documents will be matched?

medium📝 Predict Output Q4 of 15
Elasticsearch - Basic Search Queries
Given this bool query, which documents will be matched?
{"bool": {"must": [{"term": {"category": "books"}}], "must_not": [{"term": {"status": "out_of_stock"}}]}}
ADocuments in category 'books' and status 'out_of_stock'
BDocuments in category 'books' but not with status 'out_of_stock'
CDocuments not in category 'books' but with status 'out_of_stock'
DDocuments not in category 'books' and not with status 'out_of_stock'
Step-by-Step Solution
Solution:
  1. Step 1: Analyze must clause

    The must clause requires documents to have category equal to "books".
  2. Step 2: Analyze must_not clause

    The must_not clause excludes documents with status equal to "out_of_stock".
  3. Final Answer:

    Documents in category 'books' but not with status 'out_of_stock' -> Option B
  4. Quick Check:

    Must + must_not = include and exclude [OK]
Quick Trick: must includes, must_not excludes documents [OK]
Common Mistakes:
MISTAKES
  • Ignoring must_not clause
  • Confusing must and must_not effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes