我正在寻找"价格"的汇总查询嵌套字段中的字段。
每个文档的映射是
"Item": {
"id": {
"type": "integer"
}
"products":{
"properties": {
"price": {
"type": "double"
},
"name": {
"type": "string"
}
}
}
我们说我有3份文件,
Item1:
{
"id:1,
"products":[
{"name":"aa", "price":100.0}
{"name":"bb", "price":200.0}
{"name":"cc", "price":300.0}
]
}
Item2:
{
"id:2,
"products":[
{"name":"dd", "price":400.0}
{"name":"ee", "price":300.0}
]
}
Item3:
{
"id:3,
"products":[
{"name":"ff", "price":150.0}
{"name":"gg", "price":50.0}
{"name":"ff", "price":250.0}
]
}
我需要一个范围聚合查询,它汇总了每个项目的最低价格产品。
"aggregations" : {
"nested_aggs" : {
"nested" : {
"path" : "products"
},
"aggregations" : {
"price_range" : {
"range" : {
"field" : "products.price",
"ranges" : [
{
"to" : 200.0
},
{
"from" : 200.0,
"to" : 400.0
}
],
"keyed" : false
}
}
}
}
}
Expected output: 0-200: 2 (Item1 & item3)
200-400: 1 (Item2),
我无法指定聚合过滤条件来考虑最低价格的嵌套对象
非常感谢任何帮助。