Bird
0
0

You want to find documents where the "summary" field contains either "error" or "failure" but not both. Which Elasticsearch query type should you use to achieve this?

hard🚀 Application Q8 of 15
Elasticsearch - Basics and Architecture
You want to find documents where the "summary" field contains either "error" or "failure" but not both. Which Elasticsearch query type should you use to achieve this?
AA range query on the "summary" field
BA bool query with must and must_not clauses
CA term query with multiple terms
DA match_all query
Step-by-Step Solution
Solution:
  1. Step 1: Understand the requirement

    We want documents containing "error" or "failure" but not both, which is an exclusive OR condition.
  2. Step 2: Choose query type

    A bool query with must and must_not clauses can combine conditions to include one term and exclude the other.
  3. Final Answer:

    A bool query with must and must_not clauses -> Option B
  4. Quick Check:

    Exclusive OR condition = bool query with must and must_not [OK]
Quick Trick: Use bool queries to combine include and exclude conditions [OK]
Common Mistakes:
MISTAKES
  • Using match_all which returns all documents
  • Using term query without boolean logic
  • Using range query on text fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes