From a Clojure Elasticsearch aggregation query, I have a buckets vector of maps like the following where the key is a numerical identifier and the doc_count is the number of occurrences.
:buckets [{:key 14768496, :doc_count 464} {:key 14761312, :doc_count 440} {:key 14764921, :doc_count 412}]
Given a value like 14768496 I would like to be able to retrieve the doc_count, here 464.
While crafting the question I came across the following solution which I now want to share since it took me a while to find the right approach.
This produces the following map:
Now the retrieval is straightforward: