查询出图片标记的2条为空的数据
可以使用TERM的全字查询
--造数据
POST /_bulk
{"index":{"_index":"testtest","_type":"testtype","_id":"1"}}
{"doctorNumber":"11341","doctorName":""}
{"index":{"_index":"testtest","_type":"testtype","_id":"2"}}
{"doctorNumber":"11342","doctorName":""}
{"index":{"_index":"testtest","_type":"testtype","_id":"3"}}
{"doctorNumber":"1","doctorName":"1234"}
--查询
GET testtest/testtype/_search
{
"query": {
"term": {
"doctorName.keyword": {
"value": ""
}
}
}
}
--结果
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0.2876821,
"hits": [
{
"_index": "testtest",
"_type": "testtype",
"_id": "2",
"_score": 0.2876821,
"_source": {
"doctorNumber": "11342",
"doctorName": ""
}
},
{
"_index": "testtest",
"_type": "testtype",
"_id": "1",
"_score": 0.2876821,
"_source": {
"doctorNumber": "11341",
"doctorName": ""
}
}
]
}
}
接收传参是NULL,可以处理一下为空的状态
我这边需要不做处理查询,如果处理查询的话就有很大解决方法了
在入数据的时候设计空值标记如 N/A 这样可以避免此类问题
如果没法放入的时候避免为空的话可以在查询完毕后过滤掉为空的内容
试试这样的方法呢 ""
直接加一对双引号