假设我想获取数组字段中所有元素的“状态”不未知的所有文档。
例如:
[
{
"type": "object1",
"list": [
{
"node": "1",
"status": "UP"
},
{
"node": "2",
"status": "DOWN"
},
{
"node": "3",
"status": "UNKNOWN"
}
]
},
{
"type": "object2",
"list": [
{
"node": "1",
"status": "UNKNOWN"
},
{
"node": "2",
"status": "UNKNOWN"
}
]
}
]而且查询应该只返回"object1“文档,因为"object2”列表的所有元素都是未知的。
映射,我已经将它定义为一个嵌套对象,并且我已经可以搜索记录,例如,list.status=UP只想知道如何实现获取文档的用例,其中数组字段中的所有元素都不是某个值。
试过这个
{
"query": {
"bool" : {
"must_not" : {
"term" : { "list.status" : "UNKNOWN" }
}
}
}
}但是,在本例中,上面的查询不返回object1 (不是预期的),而是筛选出object2 (如预期的那样)。
发布于 2022-03-01 18:36:16
https://stackoverflow.com/questions/71312938
复制相似问题