Boolean fields accept JSON true
and false
values, but can also accept strings which are interpreted as either true or false:
false
, "false"
, ""
(empty string)
true
, "true"
For example:
PUT my-index-000001
{ "mappings": { "properties": { "is_published": { "type": "boolean" } } } } POST my-index-000001/_doc/1?refresh { "is_published": "true" } GET my-index-000001/_search { "query": { "term": { "is_published": true } } }
"true"
, which is interpreted as true
.true
.Aggregations like the terms
aggregation use 1
and 0
for the key
, and the strings "true"
and "false"
for the key_as_string
. Boolean fields when used in scripts, return true
and false
:
POST my-index-000001/_doc/1?refresh
{ "is_published": true } POST my-index-000001/_doc/2?refresh { "is_published": false } GET my-index-000001/_search { "aggs": { "publish_state": { "terms": { "field": "is_published" } } }, "sort": [ "is_published" ], "fields": [ {"field": "weight"} ], "runtime_mappings": { "weight": { "type": "long", "script": "emit(doc['is_published'].value ? 10 : 0)" } } }
The following parameters are accepted by boolean
fields:
doc_values
true
(default) or false
.
index
true
(default) and false
. Fields that only have doc_values
enabled can still be queried using term or range-based queries, albeit slower.
ignore_malformed
true
or false
. Note that this cannot be set if the script
parameter is used.
null_value
null
values. Defaults to null
, which means the field is treated as missing. Note that this cannot be set if the script
parameter is used.
on_script_error
script
parameter throws an error at indexing time. Accepts fail
(default), which will cause the entire document to be rejected, and continue
, which will register the field in the documentâs _ignored
metadata field and continue indexing. This parameter can only be set if the script
field is also set.
script
store
_source
field. Accepts true
or false
(default).
meta
time_series_dimension
(Optional, Boolean)
Marks the field as a time series dimension. Defaults to false
.
The index.mapping.dimension_fields.limit
index setting index setting limits the number of dimensions in an index.
Dimension fields have the following constraints:
doc_values
and index
mapping parameters must be true
.boolean
fields support synthetic _source
in their default configuration.
Synthetic source may sort boolean
field values. For example:
PUT idx
{ "settings": { "index": { "mapping": { "source": { "mode": "synthetic" } } } }, "mappings": { "properties": { "bool": { "type": "boolean" } } } } PUT idx/_doc/1 { "bool": [true, false, true, false] }
Will become:
{
"bool": [false, false, true, true]
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4