我有两种文件:
"doc1":{
"dummy_attribute":"HI",
...
"important_attribute":{}
}
"doc2":{
"dummy_attribute":"HI",
...
}
如果我这样搜索:
GET myindex/_search
{
"query": {
"bool": {
"must_not": [{
"exists": {
"field": "important_attribute"
}
}]
}
}
}
它还给我两份文件。有没有办法只搜索文档中实际上不存在“重要属性”的文档?
1条答案
按热度按时间xytpbqjk1#
不幸的是,这是不可能的,因为es将不存在的值视为空值(
null
,""
,[]
或者{}
).可以使用脚本字段快速检查文档是否包含空的dict,但在筛选时不能使用此上下文: