# How to analyze how many documents for specific key's each value

**URL:** <https://discuss.elastic.co/t/how-to-analyze-how-many-documents-for-specific-keys-each-value/216514>\
**Category:** Elasticsearch\
**Created:** [January 25, 2020, 11:27am UTC](https://discuss.elastic.co/t/how-to-analyze-how-many-documents-for-specific-keys-each-value/216514 "2020-01-25T11:27:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryohetoy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryohetoy/32/45582_2.png) [@ryohetoy](https://discuss.elastic.co/u/ryohetoy)\
**Post date:** [January 25, 2020, 11:27am UTC](https://discuss.elastic.co/t/how-to-analyze-how-many-documents-for-specific-keys-each-value/216514/1 "2020-01-25T11:27:42Z")

</div>

I have a `like_to_article` Index with 250,000 documents.  
This index has `article_id` key.

To analyze how many documents for each `article_id` key, how can I do that even if there are 250,000 docs?

for incetance...

- article\_id `aaa` -\> 500 docs
- article\_id `bbb` -\> 1000 docs

The one way to do that I thought, take 10,000 documents, this is max when fetch docs, 25 times, then parse the response.

I don't want to do that because this is over work a bit, only need number. Moreover, taking 10,000 docs 25times is too hard to do.

Any ideas, thank you.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [January 27, 2020, 9:43am UTC](https://discuss.elastic.co/t/how-to-analyze-how-many-documents-for-specific-keys-each-value/216514/2 "2020-01-27T09:43:27Z")

</div>

Take a look at the [terms aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-aggregations-bucket-terms-aggregation.html), allowing you to count occurences of a field value in an index.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 24, 2020, 9:43am UTC](https://discuss.elastic.co/t/how-to-analyze-how-many-documents-for-specific-keys-each-value/216514/3 "2020-02-24T09:43:35Z")

</div>

Closed on February 24, 2020, 9:43am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
