# Term facet memory consideration in the documentation

**URL:** <https://discuss.elastic.co/t/term-facet-memory-consideration-in-the-documentation/10302>\
**Category:** Elasticsearch\
**Created:** [January 10, 2013, 10:58pm UTC](https://discuss.elastic.co/t/term-facet-memory-consideration-in-the-documentation/10302 "2013-01-10T22:58:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tux\_Racer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tux_racer/32/2545_2.png) [@Tux\_Racer](https://discuss.elastic.co/u/Tux_Racer)\
**Post date:** [January 10, 2013, 10:58pm UTC](https://discuss.elastic.co/t/term-facet-memory-consideration-in-the-documentation/10302/1 "2013-01-10T22:58:02Z")

</div>

Hello List,

I am not sure I understand the 'Memory consideration' paragraph at:

[http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html)

in particular the phrase "Term facet causes the relevant field values to  
be loaded into memory. " (maybe because of my bad command of English 😉 )

If I have 100 million documents, each document having a field 'field1'  
of type 'byte', and if only 30 different values (or terms) are ever used  
across all the documents, will a term facet search on the 'field1' load  
into RAM

a) 100 million times one byte, (relevant=all the values)  
b) or just 30 times one byte, (relevant=all the distinct values)  
c) or just the N\<=30 times one byte where N is the number of documents  
matching the facet filter? (relevant=all the distinct values that one  
can possibly return with the filters)

Also, is there a way to get approximative counts per term, but with less  
memory use and/or that could be used when the count per term is really  
large?  
BTW is 1\<\<32=4294967296 the maximum count one can get, or does the count  
use a float?

Thanks  
TuXRaceR

--

---

<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:** [January 11, 2013, 2:23am UTC](https://discuss.elastic.co/t/term-facet-memory-consideration-in-the-documentation/10302/2 "2013-01-11T02:23:24Z")

</div>

IMHO, it's c)

BTW for yor last question, look at: [https://github.com/ptdavteam/elasticsearch-approx-plugin](https://github.com/ptdavteam/elasticsearch-approx-plugin)

## HTH

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 janv. 2013 à 23:58, TuX RaceR [tuxracer69@gmail.com](mailto:tuxracer69@gmail.com) a écrit :

Hello List,

I am not sure I understand the 'Memory consideration' paragraph at:

[http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html)

in particular the phrase "Term facet causes the relevant field values to be loaded into memory. " (maybe because of my bad command of English 😉 )

If I have 100 million documents, each document having a field 'field1' of type 'byte', and if only 30 different values (or terms) are ever used across all the documents, will a term facet search on the 'field1' load into RAM

a) 100 million times one byte, (relevant=all the values)  
b) or just 30 times one byte, (relevant=all the distinct values)  
c) or just the N\<=30 times one byte where N is the number of documents matching the facet filter? (relevant=all the distinct values that one can possibly return with the filters)

Also, is there a way to get approximative counts per term, but with less memory use and/or that could be used when the count per term is really large?  
BTW is 1\<\<32=4294967296 the maximum count one can get, or does the count use a float?

Thanks  
TuXRaceR

--

--

---

<div class="post-metadata">

**Author:** ![Tux\_Racer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tux_racer/32/2545_2.png) [@Tux\_Racer](https://discuss.elastic.co/u/Tux_Racer)\
**Post date:** [January 11, 2013, 11:11am UTC](https://discuss.elastic.co/t/term-facet-memory-consideration-in-the-documentation/10302/3 "2013-01-11T11:11:46Z")

</div>

Thank you David,

actually after reading

[http://elasticsearch-users.115913.n3.nabble.com/terms-facet-explodes-memory-td3258748.html](http://elasticsearch-users.115913.n3.nabble.com/terms-facet-explodes-memory-td3258748.html)

I would exclude c)

Thank you for the very interesting link

> **[GitHub - pearson-enabling-technologies/elasticsearch-approx-plugin: Plugin...](https://github.com/pearson-enabling-technologies/elasticsearch-approx-plugin)**
>
> Plugin for ElasticSearch to do approximate or exact distinct counts, and fast term lists - GitHub - pearson-enabling-technologies/elasticsearch-approx-plugin: Plugin for ElasticSearch to do approxi...

I am not sure if you can combine this plugin with a facet 'filter'. I.e  
not do only a count by date, but do a count by date for documents  
matching a condition (e.g documents belonging to a user)

Thanks  
TuXRaceR

On 01/11/2013 02:23 AM, David Pilato wrote:

> IMHO, it's c)
> 
> BTW for yor last question, look at:  
> [GitHub - pearson-enabling-technologies/elasticsearch-approx-plugin: Plugin for ElasticSearch to do approximate or exact distinct counts, and fast term lists](https://github.com/ptdavteam/elasticsearch-approx-plugin)
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 10 janv. 2013 à 23:58, TuX RaceR \<[tuxracer69@gmail.com](mailto:tuxracer69@gmail.com)  
> [mailto:tuxracer69@gmail.com](mailto:tuxracer69@gmail.com)\> a écrit :
> 
> Hello List,
> 
> I am not sure I understand the 'Memory consideration' paragraph at:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html)
> 
> in particular the phrase "Term facet causes the relevant field values  
> to be loaded into memory. " (maybe because of my bad command of  
> English 😉 )
> 
> If I have 100 million documents, each document having a field 'field1'  
> of type 'byte', and if only 30 different values (or terms) are ever  
> used across all the documents, will a term facet search on the  
> 'field1' load into RAM
> 
> a) 100 million times one byte, (relevant=all the values)  
> b) or just 30 times one byte, (relevant=all the distinct values)  
> c) or just the N\<=30 times one byte where N is the number of documents  
> matching the facet filter? (relevant=all the distinct values that one  
> can possibly return with the filters)
> 
> Also, is there a way to get approximative counts per term, but with  
> less memory use and/or that could be used when the count per term is  
> really large?  
> BTW is 1\<\<32=4294967296 the maximum count one can get, or does the  
> count use a float?
> 
> Thanks  
> TuXRaceR
> 
> --
> 
> --

--

---

<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, 2:56am UTC](https://discuss.elastic.co/t/term-facet-memory-consideration-in-the-documentation/10302/4 "2017-07-06T02:56:53Z")

</div>


