价格区间汇总
{
"aggs": {
"price_ranges": {
"range": {
"field": "price",
"ranges": [
{
"to": 50
},
{
"from": 50,
"to": 100
},
{
"from": 100
}
]
}
},
"price_stats": {
"extended_stats": {
"field": "price"
}
}
}
}
有没有办法让范围变得动态。例如,min_price代替50而max_price代替100.或者使用" price_stats.max"对于max_price?
答案 0 :(得分:1)
您可以得到这样的东西
"max_price" : { "max" : { "field" : "discountprice" } },
"min_price" : { "min" : { "field" : "discountprice" } }
然后在应用程序层中创建一个范围