不为失败找理由,要为成功找方法。

如何进行分段聚合查询

Elasticsearch | 作者 Jea | 发布于2016年11月24日 | 阅读数:5661

目前业务上有需求, 用grafana做的统计, 需要以时间为基准, 聚合出来这个字段中某个段落的聚合, 比如: filed 0-3,3-5,5-10 能否一次查询出来呢?

期望:
{
"key": vlaue,
"doc_count": 12121,
"total_count_sum": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 0-333,#这里
"doc_count": 9
}
]
}
}
已邀请:

ybtsdst - focus on lucene & es

赞同来自:

试试filters aggregation, 每段对应一个filter

要回复问题请先登录注册