[英]How to create a dynamic price range filter using elasticsearch
price range aggregations 价格范围汇总
{
"aggs": {
"price_ranges": {
"range": {
"field": "price",
"ranges": [
{
"to": 50
},
{
"from": 50,
"to": 100
},
{
"from": 100
}
]
}
},
"price_stats": {
"extended_stats": {
"field": "price"
}
}
}
}
Is there a way I can make the ranges dynamic. 有没有一种方法可以使范围动态化。 for example, min_price in place of 50 and max_price in place of 100. Or use something like "price_stats.max" for max_price? 例如,min_price代替50,max_price代替100。或者对于max_price使用“ price_stats.max”之类的东西?
You can get something like this 你可以得到这样的东西
"max_price" : { "max" : { "field" : "discountprice" } },
"min_price" : { "min" : { "field" : "discountprice" } }
then create a range in application layer 然后在应用程序层中创建范围
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.