Elastic node get OOM(Out of memory) when make estimateCost

We get OOM when function estimate Cost trying to complete. How i understand our query is too large?

Stacktrace:

Status: error. Problem Suspect 1

920 instances of org.elasticsearch.index.IndexService, loaded by jdk.internal.loader.ClassLoaders$AppClassLoader @ 0x180004140 occupy 7.49 GB (30.18%) bytes.

Most of these instances are referenced from one instance of java.util.HashMap$Node[], loaded by <system class loader>, which occupies 36.77 KB (0.00%) bytes. The instance is referenced by org.elasticsearch.indices.IndicesService @ 0x1821c7f08, loaded by jdk.internal.loader.ClassLoaders$AppClassLoader @ 0x180004140.

Thread java.lang.Thread @ 0x196941650 elasticsearch[process7][search][T#13] has a local variable or reference to org.elasticsearch.indices.IndicesService @ 0x1821c7f08 which is on the shortest path to java.util.HashMap$Node[2048] @ 0x442ff3f58. The thread java.lang.Thread @ 0x196941650 elasticsearch[process7][search][T#13] keeps local variables with total size 4.01 GB (16.16%) bytes.

Significant stack frames and local variables

org.elasticsearch.indices.IndicesService.loadIntoContext(Lorg/elasticsearch/search/internal/ShardSearchRequest;Lorg/elasticsearch/search/internal/SearchContext;Lorg/elasticsearch/search/query/QueryPhase;)V (IndicesService.java:1405)
org.elasticsearch.indices.IndicesService @ 0x1821c7f08 retains 46.16 KB (0.00%) bytes
The stacktrace of this Thread is available. See stacktrace. See stacktrace with involved local variables.

Keywords

org.elasticsearch.index.IndexService
jdk.internal.loader.ClassLoaders$AppClassLoader
java.util.HashMap$Node[]
org.elasticsearch.indices.IndicesService
org.elasticsearch.indices.IndicesService.loadIntoContext(Lorg/elasticsearch/search/internal/ShardSearchRequest;Lorg/elasticsearch/search/internal/SearchContext;Lorg/elasticsearch/search/query/QueryPhase;)V
IndicesService.java:1405
Details »
 Status: error. Problem Suspect 2

169,622 instances of org.apache.lucene.codecs.compressing.CompressingStoredFieldsReader, loaded by jdk.internal.loader.ClassLoaders$AppClassLoader @ 0x180004140 occupy 5.95 GB (23.97%) bytes.

Most of these instances are referenced from one instance of java.util.HashMap$Node[], loaded by <system class loader>, which occupies 36.77 KB (0.00%) bytes. The instance is referenced by org.elasticsearch.indices.IndicesService @ 0x1821c7f08, loaded by jdk.internal.loader.ClassLoaders$AppClassLoader @ 0x180004140.

Thread java.lang.Thread @ 0x196941650 elasticsearch[process7][search][T#13] has a local variable or reference to org.elasticsearch.indices.IndicesService @ 0x1821c7f08 which is on the shortest path to java.util.HashMap$Node[2048] @ 0x442ff3f58. The thread java.lang.Thread @ 0x196941650 elasticsearch[process7][search][T#13] keeps local variables with total size 4.01 GB (16.16%) bytes.

Significant stack frames and local variables

org.elasticsearch.indices.IndicesService.loadIntoContext(Lorg/elasticsearch/search/internal/ShardSearchRequest;Lorg/elasticsearch/search/internal/SearchContext;Lorg/elasticsearch/search/query/QueryPhase;)V (IndicesService.java:1405)
org.elasticsearch.indices.IndicesService @ 0x1821c7f08 retains 46.16 KB (0.00%) bytes
The stacktrace of this Thread is available. See stacktrace. See stacktrace with involved local variables.

Keywords

org.apache.lucene.codecs.compressing.CompressingStoredFieldsReader
jdk.internal.loader.ClassLoaders$AppClassLoader
java.util.HashMap$Node[]
org.elasticsearch.indices.IndicesService
org.elasticsearch.indices.IndicesService.loadIntoContext(Lorg/elasticsearch/search/internal/ShardSearchRequest;Lorg/elasticsearch/search/internal/SearchContext;Lorg/elasticsearch/search/query/QueryPhase;)V
IndicesService.java:1405
Details »
 Status: error. Problem Suspect 3

The thread java.lang.Thread @ 0x196941650 elasticsearch[process7][search][T#13] keeps local variables with total size 4.01 GB (16.16%) bytes.

The memory is accumulated in one instance of org.apache.lucene.search.BulkScorer[][], loaded by jdk.internal.loader.ClassLoaders$AppClassLoader @ 0x180004140, which occupies 3.96 GB (15.94%) bytes.
Significant stack frames and local variables

org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregator$FilterByFilter.estimateCost(J)J (FiltersAggregator.java:324)
org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregator$FilterByFilter @ 0x659fcfd38 retains 3.96 GB (15.94%) bytes
The stacktrace of this Thread is available. See stacktrace. See stacktrace with involved local variables.

Keywords

org.apache.lucene.search.BulkScorer[][]
jdk.internal.loader.ClassLoaders$AppClassLoader
org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregator$FilterByFilter.estimateCost(J)J
FiltersAggregator.java:324
Details »