Bird
0
0

Given this Elasticsearch mapping:

medium📝 Predict Output Q4 of 15
Elasticsearch - Mappings and Data Types
Given this Elasticsearch mapping:
{ "properties": { "status": { "type": "keyword" }, "description": { "type": "text" } } }

Which query will correctly retrieve documents where status is exactly active?
A{ "match": { "status": "active" } }
B{ "term": { "status": "active" } }
C{ "match_phrase": { "status": "active" } }
D{ "query_string": { "query": "status:active" } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand the field type

    The status field is of type keyword, which stores exact values without analysis.
  2. Step 2: Choose the correct query type

    For exact matches on keyword fields, the term query is appropriate because it does not analyze the input.
  3. Step 3: Evaluate other options

    match and match_phrase analyze the input and are suited for text fields. query_string can work but is more complex and less precise here.
  4. Final Answer:

    { "term": { "status": "active" } } -> Option B
  5. Quick Check:

    Use term query for exact keyword matches [OK]
Quick Trick: Use term query for exact keyword field filtering [OK]
Common Mistakes:
MISTAKES
  • Using match query on keyword fields
  • Assuming match_phrase works for exact keyword matches
  • Using query_string without understanding its complexity

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes