Finding Cumulative Sum for a non historgram bucket

238 views Asked by At

Is there any way we can calculate cumalative sum for a bucket which is not historgram. As per the doc we can use the cumulative_sum pipeline aggregation only in histogram.

For eg I have two term aggregation company, my_secret_key and a metric valueCount of field "my_secret_key". I want to find the cumulative sum of the value count field.

Is it possible with Elastic search ?

{
"aggregations": {
        "company": {
          "terms": {
            "field": "company.keyword"

          },
          "aggregations": {

            "my_secrey_key": {
              "terms": {
                "field": "my_secrey_key"
              },
              "aggregations": {

                "count": {
                  "value_count": {
                    "field": "my_secrey_key"
                  }
                },
                "cumulativeReviewCount" :{
                  "cumulative_sum" :{
                    "buckets_path": "count"
                  }
                }
              }
            }
          }
        }
      }
}

PS. this is what I was trying but failed because cumulative_sum only works with historgram. my_secrey_key is a string value.

0

There are 0 answers