Elasticsearch Exists 和 Missing

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html

1
2
3
4
5
6
GET /search_data/template/_search
{
"query": {
"exists" : { "field" : "gid" }
}
}

There isn’t a missing query. Instead use the exists query inside a must_not clause as follows:

1
2
3
4
5
6
7
8
9
10
GET /search_data/template/_search
{
"query": {
"bool": {
"must_not": {
"exists" : { "field" : "gid" }
}
}
}
}

Share