Bird
0
0

You want to filter documents where a boolean field is_enabled is true and a binary field file_data exists. Which Elasticsearch query correctly combines these conditions?

hard🚀 Application Q8 of 15
Elasticsearch - Mappings and Data Types
You want to filter documents where a boolean field is_enabled is true and a binary field file_data exists. Which Elasticsearch query correctly combines these conditions?
A{"bool": {"must": [{"term": {"is_enabled": true}}, {"exists": {"field": "file_data"}}]}}
B{"term": {"is_enabled": true, "file_data": true}}
C{"exists": {"field": "is_enabled"}, "term": {"file_data": true}}
D{"bool": {"should": [{"term": {"is_enabled": false}}, {"exists": {"field": "file_data"}}]}}
Step-by-Step Solution
Solution:
  1. Step 1: Understand boolean query combining conditions

    The bool query with must requires both conditions to be true.
  2. Step 2: Check each condition

    Term query checks is_enabled true, exists query checks presence of file_data.
  3. Final Answer:

    {"bool": {"must": [{"term": {"is_enabled": true}}, {"exists": {"field": "file_data"}}]}} -> Option A
  4. Quick Check:

    Use bool must to combine term and exists queries [OK]
Quick Trick: Combine conditions with bool must for AND logic [OK]
Common Mistakes:
MISTAKES
  • Using should instead of must
  • Combining term queries incorrectly
  • Misusing exists on boolean fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes