# Count of unique values in a field

**URL:** <https://discuss.elastic.co/t/count-of-unique-values-in-a-field/9464>\
**Category:** Elasticsearch\
**Created:** [October 24, 2012, 10:17pm UTC](https://discuss.elastic.co/t/count-of-unique-values-in-a-field/9464 "2012-10-24T22:17:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mike](https://discuss.elastic.co/u/Mike)\
**Post date:** [October 24, 2012, 10:17pm UTC](https://discuss.elastic.co/t/count-of-unique-values-in-a-field/9464/1 "2012-10-24T22:17:26Z")

</div>

Is there a way to get a count of the # of unique terms for a field? I know  
I can use a terms facet with a large size to get a list of all the unique  
values for a field (and their individual counts), but what if I just want  
the # of unique terms instead of the terms themselves?

--

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 24, 2012, 11:28pm UTC](https://discuss.elastic.co/t/count-of-unique-values-in-a-field/9464/2 "2012-10-24T23:28:04Z")

</div>

The termlist plugin will get you close, but it returns all the values, not  
just the count:

> **[GitHub - jprante/elasticsearch-index-termlist: Elasticsearch Index Termlist](https://github.com/jprante/elasticsearch-index-termlist/)**
>
> Elasticsearch Index Termlist. Contribute to jprante/elasticsearch-index-termlist development by creating an account on GitHub.

It shouldn't be too hard to modify the plugin to return only the counts.

--  
Ivan

On Wed, Oct 24, 2012 at 3:17 PM, Mike [mnilsson2323@gmail.com](mailto:mnilsson2323@gmail.com) wrote:

> Is there a way to get a count of the # of unique terms for a field? I  
> know I can use a terms facet with a large size to get a list of all the  
> unique values for a field (and their individual counts), but what if I just  
> want the # of unique terms instead of the terms themselves?
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Mike](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mike](https://discuss.elastic.co/u/Mike)\
**Post date:** [October 25, 2012, 1:54pm UTC](https://discuss.elastic.co/t/count-of-unique-values-in-a-field/9464/3 "2012-10-25T13:54:25Z")

</div>

Thanks Ivan

--

---

<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:** [July 6, 2017, 3:07am UTC](https://discuss.elastic.co/t/count-of-unique-values-in-a-field/9464/4 "2017-07-06T03:07:13Z")

</div>


