# How do I get a terms count of text filed?

**URL:** <https://discuss.elastic.co/t/how-do-i-get-a-terms-count-of-text-filed/245519>\
**Category:** Elasticsearch\
**Created:** [August 19, 2020, 3:41am UTC](https://discuss.elastic.co/t/how-do-i-get-a-terms-count-of-text-filed/245519 "2020-08-19T03:41:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charele](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@Charele](https://discuss.elastic.co/u/Charele)\
**Post date:** [August 19, 2020, 3:41am UTC](https://discuss.elastic.co/t/how-do-i-get-a-terms-count-of-text-filed/245519/1 "2020-08-19T03:41:12Z")

</div>

For example, "desc" is a text field (fielddata = true)

doc1 PUT {"desc", "aaa aaa aaa"}  
doc2 PUT {"desc", "aaa xxx"}

When I do a terms aggreation on it, and I will get a "doc count",  
but I want to get the term count,  
"aaa" 4  
"xxx" 1

Thanks for any reply!(DSL or Java High level are all okay)

---

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [August 25, 2020, 5:58am UTC](https://discuss.elastic.co/t/how-do-i-get-a-terms-count-of-text-filed/245519/2 "2020-08-25T05:58:29Z")

</div>

Hi,  
What you want to get is [term vectors](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/docs-termvectors.html) rather than term aggregation.

---

<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:** [September 22, 2020, 5:58am UTC](https://discuss.elastic.co/t/how-do-i-get-a-terms-count-of-text-filed/245519/3 "2020-09-22T05:58:42Z")

</div>

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