# JVm goes out of memory when I am using facets

**URL:** <https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555>\
**Category:** Elasticsearch\
**Created:** [July 29, 2012, 9:11am UTC](https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555 "2012-07-29T09:11:35Z")\
**Posts on this page:** 9\
**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 29, 2012, 9:11am UTC](https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555/1 "2012-07-29T09:11:35Z")

</div>

I am using ES version 0.19.7 . It was running fine but now jvm goes out of  
memory when I use facets.

---

<div class="post-metadata">

**Author:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [July 29, 2012, 9:41am UTC](https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555/2 "2012-07-29T09:41:37Z")

</div>

Hello!

You probably don't have enough memory to handle your faceting  
requests. If you have enough memory, you can try increasing it, if you  
don't and you can sacrifice a bit of performance you can try changing  
the field data cache type and see if it works for you. You can find  
more about ElasticSearch cache here:  
[http://www.elasticsearch.org/guide/reference/index-modules/cache.html](http://www.elasticsearch.org/guide/reference/index-modules/cache.html)  
and a post explaining a bit

> **[ElasticSearch Cache Usage](https://sematext.com/blog/elasticsearch-cache-usage/)**
>
> We’ve been doing a ton of work with ElasticSearch. Not long ago, we had a few situations where ElasticSearch would “eat” all the JVM heap memory we give it.  It was so hungry, we could not feed it…

--  
Regards,  
Rafał Kuć  
Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - ElasticSearch

I am using ES version 0.19.7 . It was running fine but now jvm goes out of memory when I use facets.

---

<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:** [July 29, 2012, 9:42am UTC](https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555/3 "2012-07-29T09:42:46Z")

</div>

Yes. It could happen.

Do you need a more precise answer?  
Please provide more details about your settings (memory you give to the Jvm), number of docs, number of different terms for the field you want to facet.

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 29 juil. 2012 à 11:11, jajoria abhishek [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) a écrit :

> I am using ES version 0.19.7 . It was running fine but now jvm goes out of memory when I use facets.

---

<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 29, 2012, 6:11pm UTC](https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555/4 "2012-07-29T18:11:06Z")

</div>

I have an index of size 4 gb with 5000 documents and 0 replica .My min heap  
size is 256m and max heap size of 1g reserved for ES. I want to calculate  
term facet for all the terms in the docs .Is there any way to do it without  
going out of memory .

On Sun, Jul 29, 2012 at 3:12 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Yes. It could happen.
> 
> Do you need a more precise answer?  
> Please provide more details about your settings (memory you give to the  
> Jvm), number of docs, number of different terms for the field you want to  
> facet.
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr
> 
> Le 29 juil. 2012 à 11:11, jajoria abhishek [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) a  
> écrit :
> 
> > I am using ES version 0.19.7 . It was running fine but now jvm goes out  
> > of memory when I use facets.

---

<div class="post-metadata">

**Author:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [July 29, 2012, 6:24pm UTC](https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555/5 "2012-07-29T18:24:08Z")

</div>

Hello!

Try increasing you maximum heap size. ElasticSearch throws OOM because it doesn't have enough memory to calculate facets.

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

I have an index of size 4 gb with 5000 documents and 0 replica .My min heap size is 256m and max heap size of 1g reserved for ES. I want to calculate term facet for all the terms in the docs .Is there any way to do it without going out of memory .

On Sun, Jul 29, 2012 at 3:12 PM, David Pilato \<[david@pilato.fr](mailto:david@pilato.fr)\> wrote:

Yes. It could happen.

Do you need a more precise answer?

Please provide more details about your settings (memory you give to the Jvm), number of docs, number of different terms for the field you want to facet.

David 😉

Twitter : @dadoonet / @elasticsearchfr

Le 29 juil. 2012 à 11:11, jajoria abhishek \<[jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com)\> a écrit :

\> I am using ES version 0.19.7 . It was running fine but now jvm goes out of memory when I use facets.

---

<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:** [July 29, 2012, 6:27pm UTC](https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555/6 "2012-07-29T18:27:16Z")

</div>

Yes. And, you have 4 gb with only 5000 documents. That means that one document have many many many fields or values.

Asking for facets on such huge fields requires lot of memory.

David.

De : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] De la part de Rafal Kuc  
Envoyé : dimanche 29 juillet 2012 20:24  
À : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
Objet : Re: JVm goes out of memory when I am using facets

Hello!

Try increasing you maximum heap size. Elasticsearch throws OOM because it doesn't have enough memory to calculate facets.

--  
Regards,  
Rafał Kuć  
Sematext :: [http://sematext.com/](http://sematext.com/) [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch

I have an index of size 4 gb with 5000 documents and 0 replica .My min heap size is 256m and max heap size of 1g reserved for ES. I want to calculate term facet for all the terms in the docs .Is there any way to do it without going out of memory .

On Sun, Jul 29, 2012 at 3:12 PM, David Pilato \< [mailto:david@pilato.fr](mailto:david@pilato.fr) [david@pilato.fr](mailto:david@pilato.fr)\> wrote:  
Yes. It could happen.

Do you need a more precise answer?  
Please provide more details about your settings (memory you give to the Jvm), number of docs, number of different terms for the field you want to facet.

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 29 juil. 2012 à 11:11, jajoria abhishek \< [mailto:jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com)\> a écrit :

> I am using ES version 0.19.7 . It was running fine but now jvm goes out of memory when I use facets.

---

<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, 5:17am UTC](https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555/7 "2012-07-30T05:17:41Z")

</div>

_David.How much would be enough or any other way to do it ._

On Sun, Jul 29, 2012 at 11:57 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Yes. And, you have 4 gb with only 5000 documents. That means that one  
> document have many many many fields or values.\*\*\*\*
> 
> Asking for facets on such huge fields requires lot of memory.\*\*\*\*
> 
> * * *
> 
> * * *
> 
> _De :_ [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) [mailto:  
> [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] _De la part de_ Rafal Kuc  
> _Envoyé :_ dimanche 29 juillet 2012 20:24  
> _À :_ [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> _Objet :_ Re: JVm goes out of memory when I am using facets\*\*\*\*
> 
> * * *
> 
> Hello!
> 
> Try increasing you maximum heap size. Elasticsearch throws OOM because it  
> doesn't have enough memory to calculate facets.
> 
> _--  
> Regards,  
> Rafał Kuć  
> Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch -  
> Elasticsearch_\*\*\*\*
> 
> I have an index of size 4 gb with 5000 documents and 0 replica .My min  
> heap size is 256m and max heap size of 1g reserved for ES. I want to  
> calculate term facet for all the terms in the docs .Is there any way to do  
> it without going out of memory .
> 
> On Sun, Jul 29, 2012 at 3:12 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Yes. It could happen.
> 
> Do you need a more precise answer?  
> Please provide more details about your settings (memory you give to the  
> Jvm), number of docs, number of different terms for the field you want to  
> facet.
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr
> 
> Le 29 juil. 2012 à 11:11, jajoria abhishek [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) a  
> écrit :
> 
> > I am using ES version 0.19.7 . It was running fine but now jvm goes out  
> > of memory when I use facets.\*\*\*\*
> 
> * * *

---

<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:** [July 30, 2012, 7:24am UTC](https://discuss.elastic.co/t/jvm-goes-out-of-memory-when-i-am-using-facets/8555/8 "2012-07-30T07:24:56Z")

</div>

Hard to say without any idea of your documents and of your use case.  
I follow some rules:

- I don't facet on fields having to much different values (let say 100 000)
- I filter facet on a smaller period (using range filter)
- I increase RAM

Try with at least 2Gb...

HTH  
David

--

Le 30 juil. 2012 à 07:17, jajoria abhishek [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) a écrit :

> David.How much would be enough or any other way to do it .
> 
> On Sun, Jul 29, 2012 at 11:57 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Yes. And, you have 4 gb with only 5000 documents. That means that one document have many many many fields or values.
> 
> Asking for facets on such huge fields requires lot of memory.
> 
> De : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] De la part de Rafal Kuc  
> Envoyé : dimanche 29 juillet 2012 20:24  
> À : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> Objet : Re: JVm goes out of memory when I am using facets
> 
> Hello!
> 
> Try increasing you maximum heap size. Elasticsearch throws OOM because it doesn't have enough memory to calculate facets.
> 
> --  
> Regards,  
> Rafał Kuć  
> Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> 
> I have an index of size 4 gb with 5000 documents and 0 replica .My min heap size is 256m and max heap size of 1g reserved for ES. I want to calculate term facet for all the terms in the docs .Is there any way to do it without going out of memory .
> 
> On Sun, Jul 29, 2012 at 3:12 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Yes. It could happen.
> 
> Do you need a more precise answer?  
> Please provide more details about your settings (memory you give to the Jvm), number of docs, number of different terms for the field you want to facet.
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr
> 
> Le 29 juil. 2012 à 11:11, jajoria abhishek [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) a écrit :
> 
> > I am using ES version 0.19.7 . It was running fine but now jvm goes out of memory when I use facets.

---

<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/jvm-goes-out-of-memory-when-i-am-using-facets/8555/9 "2017-07-06T03:18:30Z")

</div>


