1. 不是""串也不是null
{
"query": {
"bool": {
"must": [
{
"bool": {
"must_not": {
"term": {
"id": ""
}
},
"must": {
"exists": {
"field": "id"
}
}
}
}
]
}
},
"sort": [
{
"id": {
"order": "asc"
}
}
]
}
690960906
2. 是""不是null
{
"query": {
"bool": {
"must": [
{
"bool": {
"filter": {
"term": {
"id": ""
}
},
"must": {
"exists": {
"field": "id"
}
}
}
}
]
}
},
"sort": [
{
"id": {
"order": "desc"
}
}
]
}
681695941
3. 是null
4584400
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "id"
}
}
]
}
}
}
4. 将空值映射成空串
PUT my-index-000001
{
"mappings": {
"properties": {
"status_code": {
"type": "keyword",
"null_value": ""
}
}
}
}