问题:我想对特定字段进行聚合,保留其他字段的信息并获取指标的总和。
这里有一个例子的要点:https://gist.github.com/jnaour/33f237b3084d657031bc
我可以做一个黑客来解决这个问题:在一个字段中连接所有信息在这个字段上使用一个术语aggs并计算总数... 其他可能性:保留所有信息的几个等级术语aggs。
有什么方法可以做我想要的吗?
于连
答案 0 :(得分:0)
热门点击聚合将是最佳选择。 试试以下 -
{
"aggs": {
"name": {
"terms": {
"field": "station.name"
},
"aggs": {
"singleSample": {
"top_hits": {
"size": 1
}
},
"total": {
"sum": {
"field": "count"
}
}
}
}
}
}