1.区间统计.通常用于柱状图 每个范围内的量. 比如价格范围的商品数, 年龄范围的人数, 分数范围的人数等等.
可以概括为某个指标范围内的出现次数.
参考来源: http://www.cnblogs.com/xing901022
{
"aggs":{
"grade_ranges":{
"range":{
"field":"grade",
"ranges":[
{"to":60},
{"from":60,"to":80},
{"from":80}]
}
}
}
}
结果
{
...
"aggregations":{
"price_ranges":{
"buckets":[
{
"to":60,
"doc_count":2
},
{
"from":60,
"to":80,
"doc_count":32
},
{
"from":80,
"doc_count":14
}
]
}
}
}
指定区间名称
{
"aggs":{
"price_ranges":{
"range":{
"field":"price",
"keyed":true,
"ranges":[
{"key":"cheap","to":50},
{"key":"average","from":50,"to":100},
{"key":"expensive","from":100}
]
}
}
}
}
网友评论