'Elasticsearch add values of similar keys across documents?

In Elasticsearch 6.8 (or 7) I have documents with differing keys and I want to add the values across across all. For example:

{"ok":10, "mn":12, "ca":84},
{"tx":34, "mn":20, "ca":100},
{"tx":10, "ma":10, "ca":100}

I want (in some form):

 {"ok":10, "mn":42,"ca":284, "tx":44}

My end goal is to graph the sum value across each available key.

Is this workable in the current format? Is there a better format other than using a single document for each key? (The full key domain set will not be known)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source