# Aggregating object keys to achieve a sum

**URL:** <https://discuss.elastic.co/t/aggregating-object-keys-to-achieve-a-sum/296193>\
**Category:** Elasticsearch\
**Created:** [February 3, 2022, 1:40pm UTC](https://discuss.elastic.co/t/aggregating-object-keys-to-achieve-a-sum/296193 "2022-02-03T13:40:32Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![hugomeloo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugomeloo/32/101228_2.png) [@hugomeloo](https://discuss.elastic.co/u/hugomeloo)\
**Post date:** [February 3, 2022, 10:53pm UTC](https://discuss.elastic.co/t/aggregating-object-keys-to-achieve-a-sum/296193/3 "2022-02-03T22:53:57Z")

</div>

Hi @linkerc, thank your for your answer.

Actually, my document is now something like

```auto
{ "id":123, "topics": ["room", "kitchen", "room"], ... }

```

But I am not interested in the customer info when I am aggregating. I only want to know the count of the keyword repetitions inside the aggregation. So, if I have 1000 documents in one aggregation, I would count the number of times "room" appeared, also "kitchen" and 50 other keys.  
I have a possible solution [here](https://discuss.elastic.co/t/counting-each-key-of-an-array-inside-aggregation/296060/5) but it's taking a looong time and I am trying to achieve a faster aggregation.

---

_[View the full topic](https://discuss.elastic.co/t/aggregating-object-keys-to-achieve-a-sum/296193)._
