我必须在ElasticSearch查询中过滤这样的有效负载:
{
"bestPrices": {
"cia1": {},
"cia2": {}
}
}
我必须得到的结果如下:
{
"bestPrices": {
"cia1": {
"gol": {
"price1": 799,
"price2": null,
"miles": 25000
}
},
"cia2": {
"gol": {
"price1": null,
"price2": null,
"miles": null
}
}
}
}
我正在尝试exists
查询,但似乎不适用于这种特殊情况:
{
"exists": {
"field": "searchIntention.bestSalePrices.cia1"
}
}
我使用的是ElasticSearch 6.1
答案 0 :(得分:0)
Exists Query的Elasticsearch文档指定null
,[]
和[null]
符合不存在的值。因此,我相信所有其他值,包括空对象({}
)都将被视为非空。如果始终填充go1
对象的cia
成员,则可以尝试在该字段上使用exists
。
{
"exists": {
"field": "searchIntention.bestSalePrices.cia1.go1"
}
}