# ArrayIndexOutOfBounds on sort

**URL:** <https://discuss.elastic.co/t/arrayindexoutofbounds-on-sort/11271>\
**Category:** Elasticsearch\
**Created:** [March 22, 2013, 10:08pm UTC](https://discuss.elastic.co/t/arrayindexoutofbounds-on-sort/11271 "2013-03-22T22:08:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Owings](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@Michael\_Owings](https://discuss.elastic.co/u/Michael_Owings)\
**Post date:** [March 22, 2013, 10:08pm UTC](https://discuss.elastic.co/t/arrayindexoutofbounds-on-sort/11271/1 "2013-03-22T22:08:47Z")

</div>

I have an index with a relatively small number (around 36k) of largish  
documents. While searches work fine, attempts at sorting on anything other  
than \_score gives me the following error:

[2013-03-22 16:52:14,830][DEBUG][action.search.type] [Chi Demon]  
[green\_lantern\_seek][0], node[QZHa0NXTSDyonklDNiy0Bg], [P], s[STARTED]:  
Failed to execute [org.elasticsearch.action.search.SearchRequest@2e4f7bc2]  
org.elasticsearch.search.query.QueryPhaseExecutionException:  
[green\_lantern\_seek][0]:  
query[keywords:window],from[0],size[10],sort[\<custom:"timestamp":  
org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource@1be0799a\>]:  
Query Failed [Failed to execute main query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:139)  
at  
org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:316)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:243)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:75)  
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.runWorker(ThreadPoolExecutor.java:1146)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:679)  
Caused by: java.lang.ArrayIndexOutOfBoundsException: 148  
at  
org.apache.lucene.util.packed.Packed64SingleBlock$Packed64SingleBlock3.get(Packed64SingleBlock.java:308)  
at  
org.elasticsearch.index.fielddata.plain.PagedBytesAtomicFieldData$BytesValues.getValueByOrd(PagedBytesAtomicFieldData.java:140)  
at  
org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:459)  
at  
org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:452)  
at  
org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setBottom(BytesRefOrdValComparator.java:431)  
at  
org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setBottom(BytesRefOrdValComparator.java:165)  
at  
org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setNextReader(BytesRefOrdValComparator.java:410)  
at  
org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setNextReader(BytesRefOrdValComparator.java:155)  
at  
org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:97)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:602)  
at  
org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:192)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:572)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:524)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:501)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:345)  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:128)  
... 9 more

Restricting the number of results in the query (for example adding an  
additional term in the query string), and things work. So this fails:

{  
"sort" : [  
{ "title" : {"order" : "desc"} }  
]  
,  
"query" : {  
"query\_string" : { "query" : "keywords:foo" }  
}  
}

But reducing the number of query results via another term in the query  
string seems to fix the issue

{  
"sort" : [  
{ "title" : {"order" : "desc"} }  
]  
,  
"query" : {  
"query\_string" : { "query" : "keywords:foo filter:bar" }  
}  
}

I assume I'm running into some kind of resource limitation, but I'm not  
sure where to start. Any pointers would be appreciated. Thanx in advance --  
m

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [March 23, 2013, 6:36am UTC](https://discuss.elastic.co/t/arrayindexoutofbounds-on-sort/11271/2 "2013-03-23T06:36:21Z")

</div>

Can you reproduce it with a real dataset?  
Also post your mapping.

I don't think that the following really reduce the number of hits:  
{  
"sort" : [  
{ "title" : {"order" : "desc"} }  
]  
,  
"query" : {  
"query\_string" : { "query" : "keywords:foo filter:bar" }  
}  
}

So your real use case could help here.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 22 mars 2013 à 23:08, Michael Owings [tafkaks@gmail.com](mailto:tafkaks@gmail.com) a écrit :

I have an index with a relatively small number (around 36k) of largish documents. While searches work fine, attempts at sorting on anything other than \_score gives me the following error:

[2013-03-22 16:52:14,830][DEBUG][action.search.type] [Chi Demon] [green\_lantern\_seek][0], node[QZHa0NXTSDyonklDNiy0Bg], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@2e4f7bc2]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [green\_lantern\_seek][0]: query[keywords:window],from[0],size[10],sort[\<custom:"timestamp": org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource@1be0799a\>]: Query Failed [Failed to execute main query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:139)  
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:316)  
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:243)  
at org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:75)  
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.runWorker(ThreadPoolExecutor.java:1146)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:679)  
Caused by: java.lang.ArrayIndexOutOfBoundsException: 148  
at org.apache.lucene.util.packed.Packed64SingleBlock$Packed64SingleBlock3.get(Packed64SingleBlock.java:308)  
at org.elasticsearch.index.fielddata.plain.PagedBytesAtomicFieldData$BytesValues.getValueByOrd(PagedBytesAtomicFieldData.java:140)  
at org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:459)  
at org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:452)  
at org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setBottom(BytesRefOrdValComparator.java:431)  
at org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setBottom(BytesRefOrdValComparator.java:165)  
at org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setNextReader(BytesRefOrdValComparator.java:410)  
at org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setNextReader(BytesRefOrdValComparator.java:155)  
at org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:97)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:602)  
at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:192)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:572)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:524)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:501)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:345)  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:128)  
... 9 more

Restricting the number of results in the query (for example adding an additional term in the query string), and things work. So this fails:

{  
"sort" : [  
{ "title" : {"order" : "desc"} }  
]  
,  
"query" : {  
"query\_string" : { "query" : "keywords:foo" }  
}  
}

But reducing the number of query results via another term in the query string seems to fix the issue

{  
"sort" : [  
{ "title" : {"order" : "desc"} }  
]  
,  
"query" : {  
"query\_string" : { "query" : "keywords:foo filter:bar" }  
}  
}

I assume I'm running into some kind of resource limitation, but I'm not sure where to start. Any pointers would be appreciated. Thanx in advance -- m

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [March 23, 2013, 12:19pm UTC](https://discuss.elastic.co/t/arrayindexoutofbounds-on-sort/11271/3 "2013-03-23T12:19:41Z")

</div>

hey,

which version are you using, is it possible you are running beta1? I fixed  
a bug 10 days ago that looked very much like this:

> <https://github.com/elastic/elasticsearch/commit/365cde82d3e36ce67b989c81b3446dcf64de6017>
>
> Closes #2773

please lemme know which version you are running and if you run beta1 can  
you try and verify with the RC1?

simon

On Friday, March 22, 2013 11:08:47 PM UTC+1, Michael Owings wrote:

> I have an index with a relatively small number (around 36k) of largish  
> documents. While searches work fine, attempts at sorting on anything other  
> than \_score gives me the following error:
> 
> [2013-03-22 16:52:14,830][DEBUG][action.search.type] [Chi Demon]  
> [green\_lantern\_seek][0], node[QZHa0NXTSDyonklDNiy0Bg], [P], s[STARTED]:  
> Failed to execute [org.elasticsearch.action.search.SearchRequest@2e4f7bc2]  
> org.elasticsearch.search.query.QueryPhaseExecutionException:  
> [green\_lantern\_seek][0]:  
> query[keywords:window],from[0],size[10],sort[\<custom:"timestamp":  
> org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource@1be0799a\>]:  
> Query Failed [Failed to execute main query]  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:139)  
> at  
> org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:316)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:243)  
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:75)  
> 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.runWorker(ThreadPoolExecutor.java:1146)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:679)  
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 148  
> at  
> org.apache.lucene.util.packed.Packed64SingleBlock$Packed64SingleBlock3.get(Packed64SingleBlock.java:308)  
> at  
> org.elasticsearch.index.fielddata.plain.PagedBytesAtomicFieldData$BytesValues.getValueByOrd(PagedBytesAtomicFieldData.java:140)  
> at  
> org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:459)  
> at  
> org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:452)  
> at  
> org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setBottom(BytesRefOrdValComparator.java:431)  
> at  
> org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setBottom(BytesRefOrdValComparator.java:165)  
> at  
> org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setNextReader(BytesRefOrdValComparator.java:410)  
> at  
> org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setNextReader(BytesRefOrdValComparator.java:155)  
> at  
> org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:97)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:602)  
> at  
> org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:192)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:572)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:524)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:501)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:345)  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:128)  
> ... 9 more
> 
> Restricting the number of results in the query (for example adding an  
> additional term in the query string), and things work. So this fails:
> 
> {  
> "sort" : [  
> { "title" : {"order" : "desc"} }  
> ]  
> ,  
> "query" : {  
> "query\_string" : { "query" : "keywords:foo" }  
> }  
> }
> 
> But reducing the number of query results via another term in the query  
> string seems to fix the issue
> 
> {  
> "sort" : [  
> { "title" : {"order" : "desc"} }  
> ]  
> ,  
> "query" : {  
> "query\_string" : { "query" : "keywords:foo filter:bar" }  
> }  
> }
> 
> I assume I'm running into some kind of resource limitation, but I'm not  
> sure where to start. Any pointers would be appreciated. Thanx in advance --  
> m

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Michael\_Owings](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@Michael\_Owings](https://discuss.elastic.co/u/Michael_Owings)\
**Post date:** [March 23, 2013, 4:16pm UTC](https://discuss.elastic.co/t/arrayindexoutofbounds-on-sort/11271/4 "2013-03-23T16:16:26Z")

</div>

I was indeed running beta1 and upgrading to RC1 fixed the problem. Thanks  
for the fix! Cheers -- m

On Saturday, March 23, 2013 7:19:41 AM UTC-5, simonw wrote:

> hey,
> 
> which version are you using, is it possible you are running beta1? I fixed  
> a bug 10 days ago that looked very much like this:
> 
> [Use numOrds rather than numDocs as upperbound for sorting · elastic/elasticsearch@365cde8 · GitHub](https://github.com/elasticsearch/elasticsearch/commit/365cde82d3e36ce67b989c81b3446dcf64de6017)
> 
> please lemme know which version you are running and if you run beta1 can  
> you try and verify with the RC1?
> 
> simon
> 
> On Friday, March 22, 2013 11:08:47 PM UTC+1, Michael Owings wrote:
> 
> > I have an index with a relatively small number (around 36k) of largish  
> > documents. While searches work fine, attempts at sorting on anything other  
> > than \_score gives me the following error:
> > 
> > [2013-03-22 16:52:14,830][DEBUG][action.search.type] [Chi Demon]  
> > [green\_lantern\_seek][0], node[QZHa0NXTSDyonklDNiy0Bg], [P], s[STARTED]:  
> > Failed to execute [org.elasticsearch.action.search.SearchRequest@2e4f7bc2]  
> > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > [green\_lantern\_seek][0]:  
> > query[keywords:window],from[0],size[10],sort[\<custom:"timestamp":  
> > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource@1be0799a\>]:  
> > Query Failed [Failed to execute main query]  
> > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:139)  
> > at  
> > org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:316)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:243)  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:75)  
> > 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.runWorker(ThreadPoolExecutor.java:1146)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:679)  
> > Caused by: java.lang.ArrayIndexOutOfBoundsException: 148  
> > at  
> > org.apache.lucene.util.packed.Packed64SingleBlock$Packed64SingleBlock3.get(Packed64SingleBlock.java:308)  
> > at  
> > org.elasticsearch.index.fielddata.plain.PagedBytesAtomicFieldData$BytesValues.getValueByOrd(PagedBytesAtomicFieldData.java:140)  
> > at  
> > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:459)  
> > at  
> > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:452)  
> > at  
> > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setBottom(BytesRefOrdValComparator.java:431)  
> > at  
> > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setBottom(BytesRefOrdValComparator.java:165)  
> > at  
> > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setNextReader(BytesRefOrdValComparator.java:410)  
> > at  
> > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setNextReader(BytesRefOrdValComparator.java:155)  
> > at  
> > org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:97)  
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:602)  
> > at  
> > org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:192)  
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:572)  
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:524)  
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:501)  
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:345)  
> > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:128)  
> > ... 9 more
> > 
> > Restricting the number of results in the query (for example adding an  
> > additional term in the query string), and things work. So this fails:
> > 
> > {  
> > "sort" : [  
> > { "title" : {"order" : "desc"} }  
> > ]  
> > ,  
> > "query" : {  
> > "query\_string" : { "query" : "keywords:foo" }  
> > }  
> > }
> > 
> > But reducing the number of query results via another term in the query  
> > string seems to fix the issue
> > 
> > {  
> > "sort" : [  
> > { "title" : {"order" : "desc"} }  
> > ]  
> > ,  
> > "query" : {  
> > "query\_string" : { "query" : "keywords:foo filter:bar" }  
> > }  
> > }
> > 
> > I assume I'm running into some kind of resource limitation, but I'm not  
> > sure where to start. Any pointers would be appreciated. Thanx in advance --  
> > m

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [March 23, 2013, 7:48pm UTC](https://discuss.elastic.co/t/arrayindexoutofbounds-on-sort/11271/5 "2013-03-23T19:48:04Z")

</div>

thanks for reporting back! very much appreciated!

simon

On Saturday, March 23, 2013 5:16:26 PM UTC+1, Michael Owings wrote:

> I was indeed running beta1 and upgrading to RC1 fixed the problem. Thanks  
> for the fix! Cheers -- m
> 
> On Saturday, March 23, 2013 7:19:41 AM UTC-5, simonw wrote:
> 
> > hey,
> > 
> > which version are you using, is it possible you are running beta1? I  
> > fixed a bug 10 days ago that looked very much like this:
> > 
> > [Use numOrds rather than numDocs as upperbound for sorting · elastic/elasticsearch@365cde8 · GitHub](https://github.com/elasticsearch/elasticsearch/commit/365cde82d3e36ce67b989c81b3446dcf64de6017)
> > 
> > please lemme know which version you are running and if you run beta1 can  
> > you try and verify with the RC1?
> > 
> > simon
> > 
> > On Friday, March 22, 2013 11:08:47 PM UTC+1, Michael Owings wrote:
> > 
> > > I have an index with a relatively small number (around 36k) of largish  
> > > documents. While searches work fine, attempts at sorting on anything other  
> > > than \_score gives me the following error:
> > > 
> > > [2013-03-22 16:52:14,830][DEBUG][action.search.type] [Chi Demon]  
> > > [green\_lantern\_seek][0], node[QZHa0NXTSDyonklDNiy0Bg], [P], s[STARTED]:  
> > > Failed to execute [org.elasticsearch.action.search.SearchRequest@2e4f7bc2]  
> > > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > > [green\_lantern\_seek][0]:  
> > > query[keywords:window],from[0],size[10],sort[\<custom:"timestamp":  
> > > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource@1be0799a\>]:  
> > > Query Failed [Failed to execute main query]  
> > > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:139)  
> > > at  
> > > org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:316)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:243)  
> > > at  
> > > org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:75)  
> > > 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.runWorker(ThreadPoolExecutor.java:1146)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > > at java.lang.Thread.run(Thread.java:679)  
> > > Caused by: java.lang.ArrayIndexOutOfBoundsException: 148  
> > > at  
> > > org.apache.lucene.util.packed.Packed64SingleBlock$Packed64SingleBlock3.get(Packed64SingleBlock.java:308)  
> > > at  
> > > org.elasticsearch.index.fielddata.plain.PagedBytesAtomicFieldData$BytesValues.getValueByOrd(PagedBytesAtomicFieldData.java:140)  
> > > at  
> > > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:459)  
> > > at  
> > > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.binarySearch(BytesRefOrdValComparator.java:452)  
> > > at  
> > > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setBottom(BytesRefOrdValComparator.java:431)  
> > > at  
> > > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setBottom(BytesRefOrdValComparator.java:165)  
> > > at  
> > > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator.setNextReader(BytesRefOrdValComparator.java:410)  
> > > at  
> > > org.elasticsearch.index.fielddata.fieldcomparator.BytesRefOrdValComparator$PerSegmentComparator.setNextReader(BytesRefOrdValComparator.java:155)  
> > > at  
> > > org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:97)  
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:602)  
> > > at  
> > > org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:192)  
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:572)  
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:524)  
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:501)  
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:345)  
> > > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:128)  
> > > ... 9 more
> > > 
> > > Restricting the number of results in the query (for example adding an  
> > > additional term in the query string), and things work. So this fails:
> > > 
> > > {  
> > > "sort" : [  
> > > { "title" : {"order" : "desc"} }  
> > > ]  
> > > ,  
> > > "query" : {  
> > > "query\_string" : { "query" : "keywords:foo" }  
> > > }  
> > > }
> > > 
> > > But reducing the number of query results via another term in the query  
> > > string seems to fix the issue
> > > 
> > > {  
> > > "sort" : [  
> > > { "title" : {"order" : "desc"} }  
> > > ]  
> > > ,  
> > > "query" : {  
> > > "query\_string" : { "query" : "keywords:foo filter:bar" }  
> > > }  
> > > }
> > > 
> > > I assume I'm running into some kind of resource limitation, but I'm not  
> > > sure where to start. Any pointers would be appreciated. Thanx in advance --  
> > > m

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:44am UTC](https://discuss.elastic.co/t/arrayindexoutofbounds-on-sort/11271/6 "2017-07-06T02:44:58Z")

</div>


