首先需要确定的是,之所以能够设置null_value 一定是你在index数据的时候传递了这个字段,只不过数据是null,text类型不支持设置null_value
https://www.elastic.co/guide/en/elasticsearch/reference/current/null-value.html
- 创建index
PUT testnumber
{
"mappings": {
"properties": {
"test":
{
"type": "nested",
"properties": {
"age":
{
"type":"double",
"null_value":"-999999"
},
"ttt":{
"type":"keyword",
"null_value":"None"
}
}
}
}
}
}
- 插入数据
PUT testnumber/_doc/1
{
"test":{"age":0,"ttt":null}
}
PUT testnumber/_doc/2
{
"test":{"age":0.0}
}
- null查询
GET testnumber/_search
{
"query": {
"nested": {
"path": "test",
"query": {
"term": {
"test.ttt": {
"value": "None"
}
}
}
}
}
}