Cumulative sum query inside nested term aggregation > avg aggregation

Hi,

I want to calculate cumulative sum inside nested term aggregation with avg aggregation.

Document:
{
"_index" : "storagemetric",
"_type" : "metric",
"_id" : "OwjM32oBFWuNUT6ZDzMS",
"_score" : 1.0,
"_source" : {
"subscriberId" : 22222,
"createdTimestamp" : 1555976400000,
"name" : "zzz",
"metricId" : null,
"accountID" : "326952836038",
"cloudType" : "aws",
"attributes" : {
"all_bssize_average_bytes" : 11864.0,
"numberofobjects_average_count" : 3.0
},
"ts" : null
}
}

Response:

{
"key_as_string" : "1553299200000",
"key" : 1553299200000,
"doc_count" : 2,
"genres" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "zzz",
"doc_count" : 1,
"the_avg" : {
"value" : 11864.0
}
},
{
"key" : "aaaaa",
"doc_count" : 1,
"the_avg" : {
"value" : 11864.0
}
}
]
}
}

Query until nested term aggregation with avg:
POST storagemetric/metric/_search
{
"size": 0,
"aggs": {
"time-filter": {
"filter": {
"range": {
"createdTimestamp": {
"lte": "now",
"gt": "now-5M"
}
}
},
"aggs": {
"my_date_histo": {
"date_histogram": {
"field": "createdTimestamp",
"interval": "day"
},
"aggs": {
"genres": {
"terms": {
"field": "name.keyword"
},
"aggs": {
"the_avg": {
"avg": {
"field": "attributes.all_bssize_average_bytes"

              }
            }
          }
        }
      }
    }
  }
}

}
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.