Bird
0
0

You want to find documents where the status is active, exclude those with category as expired, and boost documents with priority as high. Which bool query structure achieves this?

hard🚀 Application Q8 of 15
Elasticsearch - Basic Search Queries
You want to find documents where the status is active, exclude those with category as expired, and boost documents with priority as high. Which bool query structure achieves this?
A{"bool": {"filter": [{"term": {"category": "expired"}}], "must": [{"term": {"status": "active"}}], "should": [{"term": {"priority": "high"}}]}}
B{"bool": {"must": [{"term": {"status": "active"}}], "must_not": [{"term": {"category": "expired"}}], "should": [{"term": {"priority": "high"}}]}}
C{"bool": {"must": [{"term": {"priority": "high"}}], "must_not": [{"term": {"status": "active"}}], "should": [{"term": {"category": "expired"}}]}}
D{"bool": {"filter": [{"term": {"status": "active"}}], "must_not": [{"term": {"priority": "high"}}], "should": [{"term": {"category": "expired"}}]}}
Step-by-Step Solution
Solution:
  1. Step 1: Identify required conditions

    status must be "active" so it goes in must.
  2. Step 2: Identify exclusions

    category "expired" must be excluded, so it goes in must_not.
  3. Step 3: Identify boosting conditions

    priority "high" boosts score, so it goes in should.
  4. Final Answer:

    Bool query with must for status active, must_not for category expired, and should for priority high -> Option B
  5. Quick Check:

    Must = required, must_not = exclude, should = boost [OK]
Quick Trick: Use must for required, must_not to exclude, should to boost [OK]
Common Mistakes:
MISTAKES
  • Putting exclusions in should
  • Confusing must and filter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes