布尔字段接受JSON true和false值,但也可以接受解释为true或false的字符串:
False values |
|
True values |
|
例如:
PUT my-index-000001
{
"mappings": {
"properties": {
"is_published": {
"type": "boolean"
}
}
}
}
POST my-index-000001/_doc/1?refresh
{
"is_published": "true" (1)
}
GET my-index-000001/_search
{
"query": {
"term": {
"is_published": true (2)
}
}
}
(1)用“true”为文档编制索引,该值被解释为true。