# Get count of specified field (unique-value)

**URL:** <https://discuss.elastic.co/t/get-count-of-specified-field-unique-value/104846>\
**Category:** Elasticsearch\
**Created:** [October 23, 2017, 6:58am UTC](https://discuss.elastic.co/t/get-count-of-specified-field-unique-value/104846 "2017-10-23T06:58:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [October 23, 2017, 6:58am UTC](https://discuss.elastic.co/t/get-count-of-specified-field-unique-value/104846/1 "2017-10-23T06:58:21Z")

</div>

Hi, everyone.  
I want to get the count of every different value of specified field.  
Now I am using the genre syntax "genres"  
`"aggs": { "genres" : { "terms" : { "field" : "L4_SRC_PORT"} } }`  
but the return doesn't look good

thank you in advance : )

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 23, 2017, 7:09am UTC](https://discuss.elastic.co/t/get-count-of-specified-field-unique-value/104846/2 "2017-10-23T07:09:38Z")

</div>

Look at [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html)

---

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [October 23, 2017, 7:13am UTC](https://discuss.elastic.co/t/get-count-of-specified-field-unique-value/104846/3 "2017-10-23T07:13:56Z")

</div>

I found the reference just now haha Thank u 🙂

---

<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:** [November 20, 2017, 7:14am UTC](https://discuss.elastic.co/t/get-count-of-specified-field-unique-value/104846/4 "2017-11-20T07:14:03Z")

</div>

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