我正在使用ElasticSearch v5.我正在尝试在Elasticsearch analytics percent中执行类似的操作,其中我有一个术语聚合,我想计算一个百分比,它是每个存储桶中所有存储桶总数的值.这是我的要求:
{
"query": {
"match_all": {}
},
"aggs": {
"periods": {
"terms": {
"field": "periods",
"size": 3
},
"aggs": {
"balance": {
"sum": {
"field": "balance"
}
}
}
},
"total_balance": {
"sum_bucket": {
"buckets_path": "periods>balance"
}
}
}
Run Code Online (Sandbox Code Playgroud)
}
我得到的结果如下:
{
"aggregations": {
"periods": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 1018940846,
"buckets": [
{
"key": 1177977600000,
"doc_count": 11615418,
"balance": {
"value": 2492032741768.1616
}
},
{
"key": 1185926400000,
"doc_count": 11592425,
"balance": {
"value": 2575365325406.6533
}
},
{ …Run Code Online (Sandbox Code Playgroud)