# Elasticsearch out of memory issue

**URL:** <https://discuss.elastic.co/t/elasticsearch-out-of-memory-issue/17370>\
**Category:** Elasticsearch\
**Created:** [May 6, 2014, 1:05pm UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-issue/17370 "2014-05-06T13:05:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Bahirat](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Rahul\_Bahirat](https://discuss.elastic.co/u/Rahul_Bahirat)\
**Post date:** [May 6, 2014, 1:05pm UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-issue/17370/1 "2014-05-06T13:05:28Z")

</div>

Hi  
On elasticsearch(1.1.1) we did the aggregation queries. We notice that if  
index is empty then ES node go out of memory

{  
"aggregations" : {  
"dataFilter" : {  
"filter" : {  
"and" : {  
"filters" : [ {  
"range" : {  
"startTime" : {  
"from" : "now-1d",  
"to" : "now",  
"include\_lower" : true,  
"include\_upper" : true  
}  
}  
}, {  
"not" : {  
"filter" : {  
"term" : {  
"type" : "xyz"  
}  
}  
}  
} ]  
}  
},  
"aggregations" : {  
"startTimeMinOfDayTerm" : {  
"terms" : {  
"field" : "startTimeMinOfDay",  
"size" : 0  
},  
"aggregations" : {  
"nameTerm" : {  
"terms" : {  
"field" : "name",  
"size" : 0  
},  
"aggregations" : {  
"sessionTypeTerm" : {  
"terms" : {  
"field" : "sessionType",  
"size" : 0  
},  
"aggregations" : {  
"typeTerm" : {  
"terms" : {  
"field" : "type",  
"size" : 0  
},  
"aggregations" : {  
"sizeStats" : {  
"stats" : {  
"field" : "size"  
}  
},  
"totalTimeStats" : {  
"stats" : {  
"field" : "totalTimeTaken"  
}  
},  
"Stats" : {  
"stats" : {  
"field" : "hits"  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}

stack trace of Elastic-search

[2014-05-06 12:10:00,947][DEBUG][action.search.type] [Silver Sable]  
[oss\_3][1], node[2j3OSX1gQSCudUYq8\_uTOw], [P], s[STARTED]: Failed to  
execute [org.elasticsearch.action.search.SearchRequest@1ab39e8] lastShard  
[true]  
org.elasticsearch.ElasticsearchException: Java heap space  
at  
org.elasticsearch.ExceptionsHelper.convertToRuntime(ExceptionsHelper.java:37)  
at  
org.elasticsearch.search.SearchService.createContext(SearchService.java:531)  
at  
org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:480)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:252)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:202)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:203)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:186)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)  
at java.lang.Thread.run(Thread.java:662)  
Caused by: java.lang.OutOfMemoryError: Java heap space  
at  
org.elasticsearch.common.util.BigArrays.newLongArray(BigArrays.java:446)  
at  
org.elasticsearch.search.aggregations.bucket.BucketsAggregator.(BucketsAggregator.java:46)  
at  
org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator.(StringTermsAggregator.java:65)  
at  
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.create(TermsAggregatorFactory.java:139)  
at  
org.elasticsearch.search.aggregations.support.ValueSourceAggregatorFactory.create(ValueSourceAggregatorFactory.java:58)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories.createAndRegisterContextAware(AggregatorFactories.java:53)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories.access$100(AggregatorFactories.java:38)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories$1.(AggregatorFactories.java:86)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories.createSubAggregators(AggregatorFactories.java:74)  
at  
org.elasticsearch.search.aggregations.Aggregator.(Aggregator.java:86)  
at  
org.elasticsearch.search.aggregations.bucket.BucketsAggregator.(BucketsAggregator.java:45)  
at  
org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator.(StringTermsAggregator.java:65)  
at  
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.create(TermsAggregatorFactory.java:139)  
at  
org.elasticsearch.search.aggregations.support.ValueSourceAggregatorFactory.create(ValueSourceAggregatorFactory.java:58)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories.createAndRegisterContextAware(AggregatorFactories.java:53)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories.access$100(AggregatorFactories.java:38)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories$1.(AggregatorFactories.java:86)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories.createSubAggregators(AggregatorFactories.java:74)  
at  
org.elasticsearch.search.aggregations.Aggregator.(Aggregator.java:86)  
at  
org.elasticsearch.search.aggregations.bucket.BucketsAggregator.(BucketsAggregator.java:45)  
at  
org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator.(StringTermsAggregator.java:65)  
at  
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.create(TermsAggregatorFactory.java:139)  
at  
org.elasticsearch.search.aggregations.support.ValueSourceAggregatorFactory.create(ValueSourceAggregatorFactory.java:58)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories.createAndRegisterContextAware(AggregatorFactories.java:53)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories.access$100(AggregatorFactories.java:38)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories$1.(AggregatorFactories.java:86)  
at  
org.elasticsearch.search.aggregations.AggregatorFactories.createSubAggregators(AggregatorFactories.java:74)  
at  
org.elasticsearch.search.aggregations.Aggregator.(Aggregator.java:86)  
at  
org.elasticsearch.search.aggregations.bucket.BucketsAggregator.(BucketsAggregator.java:45)  
at  
org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator.(StringTermsAggregator.java:65)  
at  
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.create(TermsAggregatorFactory.java:139)  
at  
org.elasticsearch.search.aggregations.support.ValueSourceAggregatorFactory.create(ValueSourceAggregatorFactory.java:58)

--  
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/66c61611-a303-433e-afe1-b69a4e3d0739%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/66c61611-a303-433e-afe1-b69a4e3d0739%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [May 6, 2014, 1:17pm UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-issue/17370/2 "2014-05-06T13:17:14Z")

</div>

Hi,

Multi-level term aggregations do not indeed perform very efficiently right  
now which is something that will be significantly improved in Elasticsearch  
1.2.

On Tue, May 6, 2014 at 3:05 PM, Rahul Bahirat [rahulbahirat@gmail.com](mailto:rahulbahirat@gmail.com)wrote:

> Hi  
> On elasticsearch(1.1.1) we did the aggregation queries. We notice that if  
> index is empty then ES node go out of memory
> 
> {  
> "aggregations" : {  
> "dataFilter" : {  
> "filter" : {  
> "and" : {  
> "filters" : [ {  
> "range" : {  
> "startTime" : {  
> "from" : "now-1d",  
> "to" : "now",  
> "include\_lower" : true,  
> "include\_upper" : true  
> }  
> }  
> }, {  
> "not" : {  
> "filter" : {  
> "term" : {  
> "type" : "xyz"  
> }  
> }  
> }  
> } ]  
> }  
> },  
> "aggregations" : {  
> "startTimeMinOfDayTerm" : {  
> "terms" : {  
> "field" : "startTimeMinOfDay",  
> "size" : 0  
> },  
> "aggregations" : {  
> "nameTerm" : {  
> "terms" : {  
> "field" : "name",  
> "size" : 0  
> },  
> "aggregations" : {  
> "sessionTypeTerm" : {  
> "terms" : {  
> "field" : "sessionType",  
> "size" : 0  
> },  
> "aggregations" : {  
> "typeTerm" : {  
> "terms" : {  
> "field" : "type",  
> "size" : 0  
> },  
> "aggregations" : {  
> "sizeStats" : {  
> "stats" : {  
> "field" : "size"  
> }  
> },  
> "totalTimeStats" : {  
> "stats" : {  
> "field" : "totalTimeTaken"  
> }  
> },  
> "Stats" : {  
> "stats" : {  
> "field" : "hits"  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }
> 
> stack trace of Elastic-search
> 
> [2014-05-06 12:10:00,947][DEBUG][action.search.type] [Silver Sable]  
> [oss\_3][1], node[2j3OSX1gQSCudUYq8\_uTOw], [P], s[STARTED]: Failed to  
> execute [org.elasticsearch.action.search.SearchRequest@1ab39e8] lastShard  
> [true]  
> org.elasticsearch.ElasticsearchException: Java heap space  
> at  
> org.elasticsearch.ExceptionsHelper.convertToRuntime(ExceptionsHelper.java:37)  
> at  
> org.elasticsearch.search.SearchService.createContext(SearchService.java:531)  
> at  
> org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:480)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:252)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:202)  
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:203)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:186)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)  
> at java.lang.Thread.run(Thread.java:662)  
> Caused by: java.lang.OutOfMemoryError: Java heap space  
> at  
> org.elasticsearch.common.util.BigArrays.newLongArray(BigArrays.java:446)  
> at  
> org.elasticsearch.search.aggregations.bucket.BucketsAggregator.(BucketsAggregator.java:46)  
> at  
> org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator.(StringTermsAggregator.java:65)  
> at  
> org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.create(TermsAggregatorFactory.java:139)  
> at  
> org.elasticsearch.search.aggregations.support.ValueSourceAggregatorFactory.create(ValueSourceAggregatorFactory.java:58)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories.createAndRegisterContextAware(AggregatorFactories.java:53)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories.access$100(AggregatorFactories.java:38)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories$1.(AggregatorFactories.java:86)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories.createSubAggregators(AggregatorFactories.java:74)  
> at  
> org.elasticsearch.search.aggregations.Aggregator.(Aggregator.java:86)  
> at  
> org.elasticsearch.search.aggregations.bucket.BucketsAggregator.(BucketsAggregator.java:45)  
> at  
> org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator.(StringTermsAggregator.java:65)  
> at  
> org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.create(TermsAggregatorFactory.java:139)  
> at  
> org.elasticsearch.search.aggregations.support.ValueSourceAggregatorFactory.create(ValueSourceAggregatorFactory.java:58)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories.createAndRegisterContextAware(AggregatorFactories.java:53)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories.access$100(AggregatorFactories.java:38)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories$1.(AggregatorFactories.java:86)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories.createSubAggregators(AggregatorFactories.java:74)  
> at  
> org.elasticsearch.search.aggregations.Aggregator.(Aggregator.java:86)  
> at  
> org.elasticsearch.search.aggregations.bucket.BucketsAggregator.(BucketsAggregator.java:45)  
> at  
> org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator.(StringTermsAggregator.java:65)  
> at  
> org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.create(TermsAggregatorFactory.java:139)  
> at  
> org.elasticsearch.search.aggregations.support.ValueSourceAggregatorFactory.create(ValueSourceAggregatorFactory.java:58)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories.createAndRegisterContextAware(AggregatorFactories.java:53)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories.access$100(AggregatorFactories.java:38)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories$1.(AggregatorFactories.java:86)  
> at  
> org.elasticsearch.search.aggregations.AggregatorFactories.createSubAggregators(AggregatorFactories.java:74)  
> at  
> org.elasticsearch.search.aggregations.Aggregator.(Aggregator.java:86)  
> at  
> org.elasticsearch.search.aggregations.bucket.BucketsAggregator.(BucketsAggregator.java:45)  
> at  
> org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator.(StringTermsAggregator.java:65)  
> at  
> org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.create(TermsAggregatorFactory.java:139)  
> at  
> org.elasticsearch.search.aggregations.support.ValueSourceAggregatorFactory.create(ValueSourceAggregatorFactory.java:58)
> 
> --  
> 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/66c61611-a303-433e-afe1-b69a4e3d0739%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/66c61611-a303-433e-afe1-b69a4e3d0739%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/66c61611-a303-433e-afe1-b69a4e3d0739%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/66c61611-a303-433e-afe1-b69a4e3d0739%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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/CAL6Z4j5tF3\_EsV945P1mw8g%3DSH\_qWvg46Uzjtwsrckn3PAtLgA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5tF3_EsV945P1mw8g%3DSH_qWvg46Uzjtwsrckn3PAtLgA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:31am UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-issue/17370/3 "2017-07-06T01:31:21Z")

</div>


