返回包含字段索引值的文档。
由于多种原因,文档字段的索引值可能不存在:
- 源JSON中的字段是
null或[] - 该字段已
"index" : false在映射中设置 - 字段值的长度超出
ignore_above了映射中的设置 - 字段值格式错误,并且
ignore_malformed已在映射中定义
curl -X GET "localhost:9200/_search?pretty" -H 'Content-Type: application/json' -d' { "query": { "exists": { "field": "user" } } } '
要查找缺少字段索引值的文档,请在 查询中使用must_not exists查询。
以下搜索返回缺少该user.id字段的索引值的文档。
curl -X GET "localhost:9200/_search?pretty" -H 'Content-Type: application/json' -d' { "query": { "bool": { "must_not": { "exists": { "field": "user.id" } } } } } '