Which of the following is a mistake that will cause an error when indexing a document?
medium
A. {"flag": "yes", "data": "dGVzdA=="}
B. {"flag": true, "data": "dGVzdA=="}
C. {"flag": false, "data": ""}
D. {"flag": false, "data": "dGVzdA=="}
Solution
Step 1: Check boolean field value types
The boolean field "flag" must be true or false, not strings like "yes".
Step 2: Validate binary field values
The binary field "data" expects base64 encoded strings, which "dGVzdA==" is valid for.
Final Answer:
{"flag": "yes", "data": "dGVzdA=="} -> Option A
Quick Check:
Boolean must be true/false, not string [OK]
Hint: Boolean fields accept only true or false, not strings [OK]
Common Mistakes:
Using string 'yes' or 'no' for boolean
Passing non-base64 strings to binary fields
Leaving binary field empty without quotes
5. You want to store user profile pictures in Elasticsearch using the binary type and also keep a flag if the user is verified using boolean. Which of the following mapping and document pairs is correct and efficient?