# Yet another facet/memory question

**URL:** https://discuss.elastic.co/t/yet-another-facet-memory-question/15632
**Category:** Elasticsearch
**Created:** [February 5, 2014, 11:42pm UTC](https://discuss.elastic.co/t/yet-another-facet-memory-question/15632 "2014-02-05T23:42:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![slushi](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@slushi](https://discuss.elastic.co/u/slushi)
#### Post date: [February 5, 2014, 11:42pm UTC](https://discuss.elastic.co/t/yet-another-facet-memory-question/15632/1 "2014-02-05T23:42:31Z")

</div>

I would like to facet on a user defined "keyword" field, but I know that  
high cardinality fields can cause high memory usage in elasticsearch.

- I see starting in 0.90 there is an indices.fielddata.cache.size  
parameter. If this is bounded, will it prevent all OOM issues or if the  
values for a single field can't fit in memory will it still cause an OOM?
- Also is it still true that _all_ facet values are loaded into memory  
upon facet execution? If so, what is the purpose of the fielddata filter?  
Wouldn't the values filtered from memory need to be accessed on disk again  
at some point anyways? Or the filtered values are simply excluded from  
consideration during facet execution?
- I see some older posts mentioned memory inefficiencies for multi  
valued fields. Is this still the case in 0.90?

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-fielddata.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-fielddata.html)  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#fielddata-filters](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#fielddata-filters)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b8c03166-a72d-4053-9af0-6a69e3e30cfb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b8c03166-a72d-4053-9af0-6a69e3e30cfb%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)
#### Post date: [February 6, 2014, 11:55am UTC](https://discuss.elastic.co/t/yet-another-facet-memory-question/15632/2 "2014-02-06T11:55:04Z")

</div>

The indices.fielddata.cache.size parameter indeed controls the size of the  
cache. It does not however prevents the loading of data into memory if a  
request needs it. In 1.0 a circuit breaker was introduced to fail requests  
that tries to load too much into memory  
( [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/index-modules-fielddata.html#fielddata-circuit-breaker)  
).

In general, once you facet on a field, all of its values are loaded into  
memory. This is based on the assumption that this field will be repeatedly  
used for different request needing various values. Some times not all  
values are interesting (think about a very common keyword, or some maybe  
you want to exclude all values that start with a dot). You can use filters  
to indicate those should not be used _and_ not loaded into memory and  
subsequent requests will not cause them to be loaded either.

I'm not sure which posts you refer to but indeed 0.90 has massively  
improved memory usage w.r.t previous versions.

Cheers,  
Boaz

On Thursday, February 6, 2014 12:42:31 AM UTC+1, slushi wrote:

> I would like to facet on a user defined "keyword" field, but I know that  
> high cardinality fields can cause high memory usage in elasticsearch.
> 
> - I see starting in 0.90 there is an indices.fielddata.cache.size  
> parameter. If this is bounded, will it prevent all OOM issues or if the  
> values for a single field can't fit in memory will it still cause an OOM?
> - Also is it still true that _all_ facet values are loaded into memory  
> upon facet execution? If so, what is the purpose of the fielddata filter?  
> Wouldn't the values filtered from memory need to be accessed on disk again  
> at some point anyways? Or the filtered values are simply excluded from  
> consideration during facet execution?
> - I see some older posts mentioned memory inefficiencies for multi  
> valued fields. Is this still the case in 0.90?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-fielddata.html)
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#fielddata-filters)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d02a4b6a-cf74-4085-8c7e-6eaf51404a4a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d02a4b6a-cf74-4085-8c7e-6eaf51404a4a%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:52am UTC](https://discuss.elastic.co/t/yet-another-facet-memory-question/15632/3 "2017-07-06T01:52:01Z")

</div>


