0
0
Elasticsearchquery~10 mins

Boolean and binary types in Elasticsearch - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Boolean and binary types
Start
Define Field Type
Boolean Type
Accepts true/false
Stores as true/false
Binary Type
Accepts base64 strings
Stores as binary data
Use in documents
Query & Retrieve
End
This flow shows how Elasticsearch handles Boolean and Binary types: defining fields, accepting values, storing them, and using them in documents.
Execution Sample
Elasticsearch
PUT /my_index
{
  "mappings": {
    "properties": {
      "is_active": {"type": "boolean"},
      "file_data": {"type": "binary"}
    }
  }
}
Defines an index with a boolean field 'is_active' and a binary field 'file_data'.
Execution Table
StepActionFieldInput ValueStored ValueNotes
1Define boolean fieldis_activeN/AN/AField type set to boolean
2Define binary fieldfile_dataN/AN/AField type set to binary
3Index documentis_activetruetrueBoolean true stored as true
4Index documentfile_data"SGVsbG8="<binary data>Base64 string decoded and stored
5Retrieve documentis_activeN/AtrueBoolean value retrieved as true
6Retrieve documentfile_dataN/A"SGVsbG8="Binary data returned as base64 string
7ExitN/AN/AN/AAll fields processed successfully
💡 All fields defined and data indexed and retrieved successfully.
Variable Tracker
VariableStartAfter Step 3After Step 4After Step 5After Step 6Final
is_activeundefinedtruetruetruetruetrue
file_dataundefinedundefined<binary data><binary data>"SGVsbG8=""SGVsbG8="
Key Moments - 2 Insights
Why does the binary field store base64 strings but return base64 strings on retrieval?
Because Elasticsearch expects binary data to be sent as base64 strings, it decodes and stores the raw binary internally, but when retrieving, it encodes the binary back to base64 for safe transport. See execution_table rows 4 and 6.
Can the boolean field accept strings like "true" or only boolean true/false?
Elasticsearch accepts boolean values true or false directly. Strings like "true" are converted internally if possible, but best practice is to send actual boolean values. See execution_table row 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4, what is the input value for the binary field?
A"SGVsbG8="
Btrue
C<binary data>
Dfalse
💡 Hint
Check the 'Input Value' column at step 4 in the execution_table.
At which step is the boolean value retrieved from the index?
AStep 3
BStep 6
CStep 5
DStep 2
💡 Hint
Look for 'Retrieve document' action for 'is_active' field in execution_table.
If you send the string "false" instead of boolean false to the boolean field, what likely happens?
AIt stores as string "false"
BIt stores as boolean false
CIt causes an error
DIt stores as boolean true
💡 Hint
Refer to key_moments about boolean field input handling.
Concept Snapshot
Boolean and binary types in Elasticsearch:
- Boolean fields store true/false values.
- Binary fields store base64-encoded binary data.
- Binary input must be base64 strings; stored as raw binary.
- Retrieval of binary fields returns base64 strings.
- Boolean fields accept true/false values directly.
Full Transcript
This visual execution trace shows how Elasticsearch handles Boolean and Binary types. First, fields are defined with their types. Boolean fields accept true or false values and store them as such. Binary fields accept base64 encoded strings, decode them to store raw binary data, and return base64 strings when retrieved. The execution table traces defining fields, indexing documents with these fields, and retrieving them. Variable tracking shows how values change through steps. Key moments clarify common confusions about input formats and storage. The quiz tests understanding of input values, retrieval steps, and type handling. The snapshot summarizes key points about these types in Elasticsearch.