# How to get terms and their frequency from all documents in elasticsearch. without using facets?

**URL:** <https://discuss.elastic.co/t/how-to-get-terms-and-their-frequency-from-all-documents-in-elasticsearch-without-using-facets/8562>\
**Category:** Elasticsearch\
**Created:** [July 30, 2012, 11:45am UTC](https://discuss.elastic.co/t/how-to-get-terms-and-their-frequency-from-all-documents-in-elasticsearch-without-using-facets/8562 "2012-07-30T11:45:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Jajoria](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@Abhishek\_Jajoria](https://discuss.elastic.co/u/Abhishek_Jajoria)\
**Post date:** [July 30, 2012, 11:45am UTC](https://discuss.elastic.co/t/how-to-get-terms-and-their-frequency-from-all-documents-in-elasticsearch-without-using-facets/8562/1 "2012-07-30T11:45:53Z")

</div>

I want the count of all the terms in elasticsearch index without using  
facets. I do no want to use facets because they are making my query slow .

---

<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:** [July 30, 2012, 6:32pm UTC](https://discuss.elastic.co/t/how-to-get-terms-and-their-frequency-from-all-documents-in-elasticsearch-without-using-facets/8562/2 "2012-07-30T18:32:10Z")

</div>

Jörg Prante created a plugin for this functionality:  
[GitHub - jprante/elasticsearch-index-termlist: Elasticsearch Index Termlist](https://github.com/jprante/elasticsearch-index-termlist) Note: I have  
never used it.

Announcement: [http://elasticsearch-users.115913.n3.nabble.com/Ann-Elasticsearch-Index-Termlist-Plugin-td3855426.html](http://elasticsearch-users.115913.n3.nabble.com/Ann-Elasticsearch-Index-Termlist-Plugin-td3855426.html)

--  
Ivan

On Mon, Jul 30, 2012 at 4:45 AM, jajoria abhishek  
[jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) wrote:

> I want the count of all the terms in elasticsearch index without using  
> facets. I do no want to use facets because they are making my query slow .

---

<div class="post-metadata">

**Author:** ![Vinicius\_Carvalho](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinicius_carvalho/32/770_2.png) [@Vinicius\_Carvalho](https://discuss.elastic.co/u/Vinicius_Carvalho)\
**Post date:** [July 30, 2012, 7:00pm UTC](https://discuss.elastic.co/t/how-to-get-terms-and-their-frequency-from-all-documents-in-elasticsearch-without-using-facets/8562/3 "2012-07-30T19:00:53Z")

</div>

I think the plugin only returns a list of terms on a field. I'm looking for  
something similar as well, just like luke does. Showing the rank for each  
term on the index. If your index contains a lot of unique terms, I don't  
think this plugin would fit (this was taken from the plugin announcement)

Regards

On Monday, July 30, 2012 2:32:10 PM UTC-4, Ivan Brusic wrote:

> Jörg Prante created a plugin for this functionality:  
> [GitHub - jprante/elasticsearch-index-termlist: Elasticsearch Index Termlist](https://github.com/jprante/elasticsearch-index-termlist) Note: I have  
> never used it.
> 
> Announcement:  
> [http://elasticsearch-users.115913.n3.nabble.com/Ann-Elasticsearch-Index-Termlist-Plugin-td3855426.html](http://elasticsearch-users.115913.n3.nabble.com/Ann-Elasticsearch-Index-Termlist-Plugin-td3855426.html)
> 
> --  
> Ivan
> 
> On Mon, Jul 30, 2012 at 4:45 AM, jajoria abhishek  
> [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) wrote:
> 
> > I want the count of all the terms in elasticsearch index without using  
> > facets. I do no want to use facets because they are making my query slow  
> > .

---

<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:** [July 30, 2012, 7:17pm UTC](https://discuss.elastic.co/t/how-to-get-terms-and-their-frequency-from-all-documents-in-elasticsearch-without-using-facets/8562/4 "2012-07-30T19:17:31Z")

</div>

It shouldn't be too hard to modify the plugin to support what you  
want, but performance might be slow. The difficult part of writing  
plugins for Elasticsearch is supporting data that is distributed. The  
Lucene code for collecting terms is somewhat easy relative to the rest  
of the code. Here is where Jörg actually calls out to Lucene:

[https://github.com/jprante/elasticsearch-index-termlist/blob/master/src/main/java/org/elasticsearch/action/termlist/TransportTermlistAction.java](https://github.com/jprante/elasticsearch-index-termlist/blob/master/src/main/java/org/elasticsearch/action/termlist/TransportTermlistAction.java)

You can add in logic to iterate through all the TermDocs that have the  
term and collect statistics.

Cheers,

Ivan

On Mon, Jul 30, 2012 at 12:00 PM, Vinicius Carvalho  
[viniciusccarvalho@gmail.com](mailto:viniciusccarvalho@gmail.com) wrote:

> I think the plugin only returns a list of terms on a field. I'm looking for  
> something similar as well, just like luke does. Showing the rank for each  
> term on the index. If your index contains a lot of unique terms, I don't  
> think this plugin would fit (this was taken from the plugin announcement)
> 
> Regards
> 
> On Monday, July 30, 2012 2:32:10 PM UTC-4, Ivan Brusic wrote:
> 
> > Jörg Prante created a plugin for this functionality:  
> > [GitHub - jprante/elasticsearch-index-termlist: Elasticsearch Index Termlist](https://github.com/jprante/elasticsearch-index-termlist) Note: I have  
> > never used it.
> > 
> > Announcement:  
> > [http://elasticsearch-users.115913.n3.nabble.com/Ann-Elasticsearch-Index-Termlist-Plugin-td3855426.html](http://elasticsearch-users.115913.n3.nabble.com/Ann-Elasticsearch-Index-Termlist-Plugin-td3855426.html)
> > 
> > --  
> > Ivan
> > 
> > On Mon, Jul 30, 2012 at 4:45 AM, jajoria abhishek  
> > [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) wrote:
> > 
> > > I want the count of all the terms in elasticsearch index without using  
> > > facets. I do no want to use facets because they are making my query slow  
> > > .

---

<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:18am UTC](https://discuss.elastic.co/t/how-to-get-terms-and-their-frequency-from-all-documents-in-elasticsearch-without-using-facets/8562/5 "2017-07-06T03:18:26Z")

</div>


