% curl -s 'localhost:9200/logstash-*/_search?pretty' -d @req.json | jq '[ .aggregations["2"].buckets[] | { key: (.key_as_string), value: (.["3"].buckets[]["4"].buckets | .[1]["doc_count"] / .[0]["doc_count"]) } ] | [ .[].value ] | length as $count | add / $count'
0.005472730173337497