Bird
0
0

You wrote this mapping:

medium📝 Debug Q6 of 15
Elasticsearch - Mappings and Data Types
You wrote this mapping:
{"properties": {"flag": {"type": "boolean"}}}

But your query {"term": {"flag": "true"}} returns no results. Why?
ABoolean fields require true/false without quotes
BThe field name is incorrect
CTerm query does not work on boolean fields
DThe mapping is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Check query value type

    Boolean fields expect true or false as boolean literals, not strings.
  2. Step 2: Identify cause of no results

    Using "true" as a string does not match the boolean true value, so no documents match.
  3. Final Answer:

    Boolean fields require true/false without quotes -> Option A
  4. Quick Check:

    Boolean query values must be boolean literals [OK]
Quick Trick: Use true/false literals, not strings, for boolean queries [OK]
Common Mistakes:
MISTAKES
  • Using strings "true" or "false"
  • Assuming term query fails on booleans
  • Incorrect field name in query

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes