I am trying to divide the value count of different groups obtained through terms aggregation with total count of all the groups. below is the code I have written. I am able to get the value count of different buckets and total count as well. But I am not able to run the bucket script over the two values. the error I am getting is "Validation Failed: 1: No aggregation [sum_buckets] found for path [latest_version>latest_version_count>sum_buckets];".
Also I would like to know how to get the graph for this proportion values over time. I tried doing this in TSVB, but I could not do the math aggregation on two series i.e one series with filter to get bucket doc_count and other for overall count. is there any other way to get this done. Any help would be greatly appreciated.
I am trying to divide the value count of different groups obtained through terms aggregation with total count of all the groups. below is the code I have written. I am able to get the value count of different buckets and total count as well. But I am not able to run the bucket script over the two values. the error I am getting is "Validation Failed: 1: No aggregation [sum_buckets] found for path [latest_version>latest_version_count>sum_buckets];".
Also I would like to know how to get the graph for this proportion values over time. I tried doing this in TSVB, but I could not do the math aggregation on two series i.e one series with filter to get bucket doc_count and other for overall count. is there any other way to get this done. Any help would be greatly appreciated.
{ "size": 0, "aggs": { "BAR": { "date_histogram": { "field": "timestamp", "calendar_interval": "day" }, "aggs": { "latest_version": { "filter": { "match_phrase": { "log": "searchBarTap" } }, "aggs": { "latest_version_count": { "terms": { "field": "log.keyword" }, "aggs": { "version_count": { "value_count": { "field": "log.keyword" } } } }, "sum_buckets": { "sum_bucket": { "buckets_path": "latest_version_count>_count" } } } }, "BAR-percentage": { "bucket_script": { "buckets_path": { "latestVersionCount": "latest_version>latest_version_count>version_count", "totalVersionCount": "latest_version>latest_version_count>sum_buckets" }, "script": "params.latestVersionCount/params.totalVersionCount" } }
} }