I provided some feedback on the OP's own answer but figured it was worth providing as an answer in its own right:
user> (def buckets [{:key 14768496, :doc_count 464} {:key 14761312, :doc_count 440} {:key 14764921, :doc_count 412}])
#'user/buckets
user=> (def accounts (into {} (map (juxt :key :doc_count)) buckets))
#'user/accounts
This uses the transducer-producing arity of map
as the "xform" argument to into
so it avoids creating any intermediate lazy sequences.
You could also do (into {} (map (juxt :key :doc_count) buckets))
which will produce a lazy sequence of vector pairs (of the key and the document count), and then "pour" it into an empty hash map.
juxt
returns a function of one parameter that produces a vector from the application of each argument (the functions passed to juxt
) to that parameter:
user=> ((juxt inc dec) 42)
[43 41]