elasticsearch/elasticsearch — Issue #1575: Two different indexes with the same nested object name causing ArrayIndexOutOfBoundsException
Author: jasongilman
Created: 2011-12-28 18:12:08+00:00
State: open

If two different mappings are created within an index that both have a nested object with the same name an ArrayIndexOutOfBoundsException can occur during searches. See this gist to reproduce: https://gist.github.com/1528898

The gist creates an index called main with two mappings alpha and bravo. Alpha and bravo both have a nested object called charlies. The gist indexes two alphas and a bravo. Only the bravo has a nested document. When searching for an alpha using a nested query an ArrayIndexOutOfBoundsException can occur. This error only occurs if the alpha was indexed before the bravo.

This issue is related to the group discussion here: https://groups.google.com/group/elasticsearch/browse_thread/thread/486e7568f82c216a

The stack trace for the exception:
```
org.elasticsearch.search.query.QueryPhaseExecutionException: [main][1]: query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.AndFilter@91837b24))->FilterCacheFilterWrapper(_type:alpha)],from[0],size[10]: Query Failed [Failed to execute main query]
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:221)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:238)
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:134)
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at org.apache.lucene.util.OpenBitSetIterator.advance(OpenBitSetIterator.java:166)
at org.elasticsearch.common.lucene.docset.AndDocIdSet$AndDocIdSetIterator.advance(AndDocIdSet.java:127)
at org.apache.lucene.search.DeletionAwareConstantScoreQuery$DeletionConstantScorer.advance(DeletionAwareConstantScoreQuery.java:91)
at org.apache.lucene.search.FilteredQuery$2.score(FilteredQuery.java:157)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:581)
at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:199)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:445)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:426)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:342)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:330)
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:217)
... 9 more
```