# Index out of bound exception on aggregation

**URL:** <https://discuss.elastic.co/t/index-out-of-bound-exception-on-aggregation/303763>\
**Category:** Elasticsearch\
**Created:** [May 2, 2022, 5:56pm UTC](https://discuss.elastic.co/t/index-out-of-bound-exception-on-aggregation/303763 "2022-05-02T17:56:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_Strickland](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Bob\_Strickland](https://discuss.elastic.co/u/Bob_Strickland)\
**Post date:** [May 2, 2022, 5:56pm UTC](https://discuss.elastic.co/t/index-out-of-bound-exception-on-aggregation/303763/1 "2022-05-02T17:56:51Z")

</div>

Working on a small index that has 1556 documents. We are getting an exception when running the following:

```auto
GET search_stage_jacked_backup_3/_search?&error_trace=true
{
  "aggs": {
    "parentDealerName": {
      "terms": {
        "field": "parentDealerName.keyword",
        "missing": "None"
      }
    }
  },
  "size" : 0
}

```

Execption:  
{  
"error": {  
"root\_cause": [  
{  
"type": "array\_index\_out\_of\_bounds\_exception",  
"reason": "Index -1 out of bounds for length 1",  
"stack\_trace": "org.Elasticsearch.ElasticsearchException$1: Index -1 out of bounds for length 1\n\tat org.Elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:638)\n\tat org.Elasticsearch.action.search.SearchPhaseExecutionException.guessRootCauses(SearchPhaseExecutionException.java:150)\n\tat org.Elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:620)\n\tat org.Elasticsearch.ElasticsearchException.generateFailureXContent(ElasticsearchException.java:566)\n\tat org.Elasticsearch.rest.BytesRestResponse.build(BytesRestResponse.java:140)\n\tat org.Elasticsearch.rest.BytesRestResponse.(BytesRestResponse.java:101)\n\tat org.Elasticsearch.rest.BytesRestResponse.(BytesRestResponse.java:81)\n\tat org.Elasticsearch.rest.action.RestActionListener.onFailure(RestActionListener.java:55)\n\tat org.Elasticsearch.rest.action.RestCancellableNodeClient$1.onFailure(RestCancellableNodeClient.java:96)\n\tat org.Elasticsearch.client.node.NodeClient.lambda$executeLocally$1(NodeClient.java:114)\n\tat org.Elasticsearch.tasks.TaskManager$1.onFailure(TaskManager.java:185)\n\tat org.Elasticsearch.action.ActionListener$Delegating.onFailure(ActionListener.java:66)\n\tat org.Elasticsearch.action.ActionListener$RunAfterActionListener.onFailure(ActionListener.java:350)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.raisePhaseFailure(AbstractSearchAsyncAction.java:748)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:725)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:412)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:757)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:509)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction$1.onFailure(AbstractSearchAsyncAction.java:343)\n\tat org.Elasticsearch.action.ActionListener$Delegating.onFailure(ActionListener.java:66)\n\tat org.Elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:48)\n\tat org.Elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:651)\n\tat org.Elasticsearch.transport.TransportService$4.handleException(TransportService.java:719)\n\tat org.Elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1343)\n\tat org.Elasticsearch.transport.InboundHandler.lambda$handleException$3(InboundHandler.java:366)\n\tat org.Elasticsearch.common.util.concurrent.EsExecutors$DirectExecutorService.execute(EsExecutors.java:221)\n\tat org.Elasticsearch.transport.InboundHandler.handleException(InboundHandler.java:364)\n\tat org.Elasticsearch.transport.InboundHandler.handlerResponseError(InboundHandler.java:356)\n\tat org.Elasticsearch.transport.InboundHandler.messageReceived(InboundHandler.java:132)\n\tat org.Elasticsearch.transport.InboundHandler.inboundMessage(InboundHandler.java:88)\n\tat org.Elasticsearch.transport.TcpTransport.inboundMessage(TcpTransport.java:728)\n\tat org.Elasticsearch.transport.InboundPipeline.forwardFragments(InboundPipeline.java:148)\n\tat org.Elasticsearch.transport.InboundPipeline.doHandleBytes(InboundPipeline.java:120)\n\tat org.Elasticsearch.transport.InboundPipeline.handleBytes(InboundPipeline.java:85)\n\tat org.Elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:70)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:280)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:620)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:583)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)\n\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n\tat java.base/java.lang.Thread.run(Thread.java:833)\nCaused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1\n\tat org.apache.lucene.util.packed.DirectMonotonicReader.get(DirectMonotonicReader.java:161)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.getTermFromIndex(Lucene90DocValuesProducer.java:1125)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekTermsIndex(Lucene90DocValuesProducer.java:1137)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekBlock(Lucene90DocValuesProducer.java:1163)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekCeil(Lucene90DocValuesProducer.java:1194)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$BaseSortedDocValues.lookupTerm(Lucene90DocValuesProducer.java:987)\n\tat org.apache.lucene.index.SingletonSortedSetDocValues.lookupTerm(SingletonSortedSetDocValues.java:100)\n\tat org.Elasticsearch.search.aggregations.support.MissingValues.replaceMissing(MissingValues.java:238)\n\tat org.Elasticsearch.search.aggregations.support.MissingValues$6.ordinalsValues(MissingValues.java:210)\n\tat org.Elasticsearch.search.aggregations.bucket.terms.GlobalOrdinalsStringTermsAggregator$LowCardinality.getLeafCollector(GlobalOrdinalsStringTermsAggregator.java:306)\n\tat org.Elasticsearch.search.aggregations.AggregatorBase.getLeafCollector(AggregatorBase.java:216)\n\tat org.Elasticsearch.search.aggregations.MultiBucketCollector$1.getLeafCollector(MultiBucketCollector.java:94)\n\tat org.Elasticsearch.search.aggregations.MultiBucketCollector$1.getLeafCollector(MultiBucketCollector.java:75)\n\tat org.apache.lucene.search.MultiCollector.getLeafCollector(MultiCollector.java:124)\n\tat org.Elasticsearch.search.internal.ContextIndexSearcher.searchLeaf(ContextIndexSearcher.java:182)\n\tat org.Elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:167)\n\tat org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:541)\n\tat org.Elasticsearch.search.query.QueryPhase.searchWithCollector(QueryPhase.java:232)\n\tat org.Elasticsearch.search.query.QueryPhase.executeInternal(QueryPhase.java:187)\n\tat org.Elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:88)\n\tat org.Elasticsearch.indices.IndicesService.lambda$loadIntoContext$26(IndicesService.java:1504)\n\tat org.Elasticsearch.indices.IndicesService.lambda$cacheShardLevelResult$27(IndicesService.java:1570)\n\tat org.Elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:178)\n\tat org.Elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:161)\n\tat org.Elasticsearch.common.cache.Cache.computeIfAbsent(Cache.java:418)\n\tat org.Elasticsearch.indices.IndicesRequestCache.getOrCompute(IndicesRequestCache.java:124)\n\tat org.Elasticsearch.indices.IndicesService.cacheShardLevelResult(IndicesService.java:1576)\n\tat org.Elasticsearch.indices.IndicesService.loadIntoContext(IndicesService.java:1498)\n\tat org.Elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:456)\n\tat org.Elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:621)\n\tat org.Elasticsearch.search.SearchService.lambda$executeQueryPhase$2(SearchService.java:483)\n\tat org.Elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47)\n\tat org.Elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62)\n\tat org.Elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat org.Elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)\n\tat org.Elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:776)\n\tat org.Elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.lang.Thread.run(Thread.java:833)\n"  
}  
],  
"type": "search\_phase\_execution\_exception",  
"reason": "all shards failed",  
"phase": "query",  
"grouped": true,  
"failed\_shards": [  
{  
"shard": 0,  
"index": "search\_stage\_jacked\_backup\_3",  
"node": "I3zlYuLGTqi6DtXxO49nRw",  
"reason": {  
"type": "array\_index\_out\_of\_bounds\_exception",  
"reason": "Index -1 out of bounds for length 1",  
"stack\_trace": "java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1... (removed for POST)"  
}  
}  
],  
"caused\_by": {  
"type": "array\_index\_out\_of\_bounds\_exception",  
"reason": "Index -1 out of bounds for length 1",  
"caused\_by": {  
"type": "array\_index\_out\_of\_bounds\_exception",  
"reason": "Index -1 out of bounds for length 1",  
"stack\_trace": "java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1... (removed for POST)"  
},  
"stack\_trace": "org.Elasticsearch.ElasticsearchException$1: Index -1 out of bounds for length 11... (removed for POST)"  
},  
"stack\_trace": "Failed to execute phase [query], all shards failed; shardFailures {[I3zlYuLGTqi6DtXxO49nRw][search\_stage\_jacked\_backup\_3][0]: org.Elasticsearch.transport.RemoteTransportException: [es02][172.18.0.4:9300][indices:data/read/search[phase/query]]\nCaused by: org.Elasticsearch.search.query.QueryPhaseExecutionException: Query Failed [Failed to execute main query]\n\tat org.Elasticsearch.search.query.QueryPhase.executeInternal(QueryPhase.java:205)\n\tat org.Elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:88)\n\tat org.Elasticsearch.indices.IndicesService.lambda$loadIntoContext$26(IndicesService.java:1504)\n\tat org.Elasticsearch.indices.IndicesService.lambda$cacheShardLevelResult$27(IndicesService.java:1570)\n\tat org.Elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:178)\n\tat org.Elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:161)\n\tat org.Elasticsearch.common.cache.Cache.computeIfAbsent(Cache.java:418)\n\tat org.Elasticsearch.indices.IndicesRequestCache.getOrCompute(IndicesRequestCache.java:124)\n\tat org.Elasticsearch.indices.IndicesService.cacheShardLevelResult(IndicesService.java:1576)\n\tat org.Elasticsearch.indices.IndicesService.loadIntoContext(IndicesService.java:1498)\n\tat org.Elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:456)\n\tat org.Elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:621)\n\tat org.Elasticsearch.search.SearchService.lambda$executeQueryPhase$2(SearchService.java:483)\n\tat org.Elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47)\n\tat org.Elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62)\n\tat org.Elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat org.Elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)\n\tat org.Elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:776)\n\tat org.Elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.lang.Thread.run(Thread.java:833)\nCaused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1\n\tat org.apache.lucene.util.packed.DirectMonotonicReader.get(DirectMonotonicReader.java:161)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.getTermFromIndex(Lucene90DocValuesProducer.java:1125)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekTermsIndex(Lucene90DocValuesProducer.java:1137)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekBlock(Lucene90DocValuesProducer.java:1163)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekCeil(Lucene90DocValuesProducer.java:1194)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$BaseSortedDocValues.lookupTerm(Lucene90DocValuesProducer.java:987)\n\tat org.apache.lucene.index.SingletonSortedSetDocValues.lookupTerm(SingletonSortedSetDocValues.java:100)\n\tat org.Elasticsearch.search.aggregations.support.MissingValues.replaceMissing(MissingValues.java:238)\n\tat org.Elasticsearch.search.aggregations.support.MissingValues$6.ordinalsValues(MissingValues.java:210)\n\tat org.Elasticsearch.search.aggregations.bucket.terms.GlobalOrdinalsStringTermsAggregator$LowCardinality.getLeafCollector(GlobalOrdinalsStringTermsAggregator.java:306)\n\tat org.Elasticsearch.search.aggregations.AggregatorBase.getLeafCollector(AggregatorBase.java:216)\n\tat org.Elasticsearch.search.aggregations.MultiBucketCollector$1.getLeafCollector(MultiBucketCollector.java:94)\n\tat org.Elasticsearch.search.aggregations.MultiBucketCollector$1.getLeafCollector(MultiBucketCollector.java:75)\n\tat org.apache.lucene.search.MultiCollector.getLeafCollector(MultiCollector.java:124)\n\tat org.Elasticsearch.search.internal.ContextIndexSearcher.searchLeaf(ContextIndexSearcher.java:182)\n\tat org.Elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:167)\n\tat org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:541)\n\tat org.Elasticsearch.search.query.QueryPhase.searchWithCollector(QueryPhase.java:232)\n\tat org.Elasticsearch.search.query.QueryPhase.executeInternal(QueryPhase.java:187)\n\t... 21 more\n}\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:725)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:412)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:757)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:509)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction$1.onFailure(AbstractSearchAsyncAction.java:343)\n\tat org.Elasticsearch.action.ActionListener$Delegating.onFailure(ActionListener.java:66)\n\tat org.Elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:48)\n\tat org.Elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:651)\n\tat org.Elasticsearch.transport.TransportService$4.handleException(TransportService.java:719)\n\tat org.Elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1343)\n\tat org.Elasticsearch.transport.InboundHandler.lambda$handleException$3(InboundHandler.java:366)\n\tat org.Elasticsearch.common.util.concurrent.EsExecutors$DirectExecutorService.execute(EsExecutors.java:221)\n\tat org.Elasticsearch.transport.InboundHandler.handleException(InboundHandler.java:364)\n\tat org.Elasticsearch.transport.InboundHandler.handlerResponseError(InboundHandler.java:356)\n\tat org.Elasticsearch.transport.InboundHandler.messageReceived(InboundHandler.java:132)\n\tat org.Elasticsearch.transport.InboundHandler.inboundMessage(InboundHandler.java:88)\n\tat org.Elasticsearch.transport.TcpTransport.inboundMessage(TcpTransport.java:728)\n\tat org.Elasticsearch.transport.InboundPipeline.forwardFragments(InboundPipeline.java:148)\n\tat org.Elasticsearch.transport.InboundPipeline.doHandleBytes(InboundPipeline.java:120)\n\tat org.Elasticsearch.transport.InboundPipeline.handleBytes(InboundPipeline.java:85)\n\tat org.Elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:70)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:280)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:620)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:583)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)\n\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n\tat java.base/java.lang.Thread.run(Thread.java:833)\nCaused by: org.Elasticsearch.ElasticsearchException$1: Index -1 out of bounds for length 1\n\tat org.Elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:638)\n\tat org.Elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:410)\n\t... 42 more\nCaused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1\n\tat org.apache.lucene.util.packed.DirectMonotonicReader.get(DirectMonotonicReader.java:161)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.getTermFromIndex(Lucene90DocValuesProducer.java:1125)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekTermsIndex(Lucene90DocValuesProducer.java:1137)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekBlock(Lucene90DocValuesProducer.java:1163)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekCeil(Lucene90DocValuesProducer.java:1194)\n\tat org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$BaseSortedDocValues.lookupTerm(Lucene90DocValuesProducer.java:987)\n\tat org.apache.lucene.index.SingletonSortedSetDocValues.lookupTerm(SingletonSortedSetDocValues.java:100)\n\tat org.Elasticsearch.search.aggregations.support.MissingValues.replaceMissing(MissingValues.java:238)\n\tat org.Elasticsearch.search.aggregations.support.MissingValues$6.ordinalsValues(MissingValues.java:210)\n\tat org.Elasticsearch.search.aggregations.bucket.terms.GlobalOrdinalsStringTermsAggregator$LowCardinality.getLeafCollector(GlobalOrdinalsStringTermsAggregator.java:306)\n\tat org.Elasticsearch.search.aggregations.AggregatorBase.getLeafCollector(AggregatorBase.java:216)\n\tat org.Elasticsearch.search.aggregations.MultiBucketCollector$1.getLeafCollector(MultiBucketCollector.java:94)\n\tat org.Elasticsearch.search.aggregations.MultiBucketCollector$1.getLeafCollector(MultiBucketCollector.java:75)\n\tat org.apache.lucene.search.MultiCollector.getLeafCollector(MultiCollector.java:124)\n\tat org.Elasticsearch.search.internal.ContextIndexSearcher.searchLeaf(ContextIndexSearcher.java:182)\n\tat org.Elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:167)\n\tat org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:541)\n\tat org.Elasticsearch.search.query.QueryPhase.searchWithCollector(QueryPhase.java:232)\n\tat org.Elasticsearch.search.query.QueryPhase.executeInternal(QueryPhase.java:187)\n\tat org.Elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:88)\n\tat org.Elasticsearch.indices.IndicesService.lambda$loadIntoContext$26(IndicesService.java:1504)\n\tat org.Elasticsearch.indices.IndicesService.lambda$cacheShardLevelResult$27(IndicesService.java:1570)\n\tat org.Elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:178)\n\tat org.Elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:161)\n\tat org.Elasticsearch.common.cache.Cache.computeIfAbsent(Cache.java:418)\n\tat org.Elasticsearch.indices.IndicesRequestCache.getOrCompute(IndicesRequestCache.java:124)\n\tat org.Elasticsearch.indices.IndicesService.cacheShardLevelResult(IndicesService.java:1576)\n\tat org.Elasticsearch.indices.IndicesService.loadIntoContext(IndicesService.java:1498)\n\tat org.Elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:456)\n\tat org.Elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:621)\n\tat org.Elasticsearch.search.SearchService.lambda$executeQueryPhase$2(SearchService.java:483)\n\tat org.Elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47)\n\tat org.Elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62)\n\tat org.Elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat org.Elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)\n\tat org.Elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:776)\n\tat org.Elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.lang.Thread.run(Thread.java:833)\n"  
},  
"status": 500  
}

I am able to run the following and the new index can have the aggregation run on it without error:

```auto
POST _reindex
{
  "source": {
    "index": "search_stage_jacked_backup_3"
  },
  "dest": {
    "index": "search_stage_reindex_backup_3"
  }
}

```

Wrote an app that recursively tried run aggregation and then deleted a document. The "offending" document had the following value:  
"parentDealerName" : null,

But that document can be posted to a good index and no problems running aggregation.

Mapping for property:

```auto
 "parentDealerName" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },

```

If I don't pass in "missing": "None" everything works fine.

Any ideas on how to trouble shoot/solve this problem would be greatly appreciated.

Thanks in advance

---

<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:** [May 30, 2022, 5:57pm UTC](https://discuss.elastic.co/t/index-out-of-bound-exception-on-aggregation/303763/2 "2022-05-30T17:57:49Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

---

<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:** [June 1, 2022, 9:23pm UTC](https://discuss.elastic.co/t/index-out-of-bound-exception-on-aggregation/303763/3 "2022-06-01T21:23:32Z")

</div>

You seem to be hitting [[LUCENE-10401] Seeking on empty doc-value terms dictionaries fails with AIOOBE - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-10401), which got fixed in Lucene 9.1 / Elasticsearch 8.2. Upgrading should fix the problem.
