# Grouping values of specific field with count

**URL:** <https://discuss.elastic.co/t/grouping-values-of-specific-field-with-count/109082>\
**Category:** Elasticsearch\
**Created:** [November 24, 2017, 8:58pm UTC](https://discuss.elastic.co/t/grouping-values-of-specific-field-with-count/109082 "2017-11-24T20:58:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wassx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wassx/32/24440_2.png) [@wassx](https://discuss.elastic.co/u/wassx)\
**Post date:** [November 24, 2017, 8:58pm UTC](https://discuss.elastic.co/t/grouping-values-of-specific-field-with-count/109082/1 "2017-11-24T20:58:52Z")

</div>

Hi!  
I can't find a query to get all distinct values of a field grouped and with a count of their occurrance.

So i have e.g. 10 documents with a field "info". "Info" has various values.  
Output should be something like:  
["infoValue1"] = 3;  
["infoValueXYZ"] = 1;  
["infoValueWhatever"] = 6;

Do you have an idea please, how I can achieve this?

---

<div class="post-metadata">

**Author:** ![krishan](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@krishan](https://discuss.elastic.co/u/krishan)\
**Post date:** [November 25, 2017, 8:11am UTC](https://discuss.elastic.co/t/grouping-values-of-specific-field-with-count/109082/2 "2017-11-25T08:11:06Z")

</div>

Use terms aggregation.Here  
[https://www.elastic.co/guide/en/elasticsearch/reference/5.5/search-aggregations-bucket-terms-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/search-aggregations-bucket-terms-aggregation.html)

---

<div class="post-metadata">

**Author:** ![wassx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wassx/32/24440_2.png) [@wassx](https://discuss.elastic.co/u/wassx)\
**Post date:** [November 28, 2017, 9:40pm UTC](https://discuss.elastic.co/t/grouping-values-of-specific-field-with-count/109082/3 "2017-11-28T21:40:27Z")

</div>

Ah I see! Thank you very much.

---

<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:** [December 26, 2017, 9:41pm UTC](https://discuss.elastic.co/t/grouping-values-of-specific-field-with-count/109082/4 "2017-12-26T21:41:08Z")

</div>

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