Error while sorting on fields which are not present for some of the documents

This issue is experienced on version 0.90.3
Searching in two indexes with sort on two fields, for one of the indices
one of the fields is present, for another - it is not. 'ignore_unmapped' is
set to true for both of the fields.

"sort" : [
{
"_subtype": {
"order": "desc",
"ignore_unmapped": true
}
},
{
"fileSize": {
"order": "asc",
"ignore_unmapped": true
}
}
]

The result for JSON search is:

{
error: ReduceSearchPhaseException[Failed to execute phase [query],
[reduce] ]; nested: ArrayIndexOutOfBoundsException[1];
status: 500
}

When searchhing with Java API:

org.elasticsearch.action.search.ReduceSearchPhaseException: Failed to
execute phase [query], [reduce]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.executeFetchPhase(TransportSearchDfsQueryThenFetchAction.java:172)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction$3.onResult(TransportSearchDfsQueryThenFetchAction.java:150)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction$3.onResult(TransportSearchDfsQueryThenFetchAction.java:144)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:176)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.executeQuery(TransportSearchDfsQueryThenFetchAction.java:144)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction$2.run(TransportSearchDfsQueryThenFetchAction.java:131)
~[elasticsearch-0.90.3.jar:na]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
~[na:1.7.0_25]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
~[na:1.7.0_25]
at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at
org.elasticsearch.search.controller.ShardFieldDocSortedHitQueue.lessThan(ShardFieldDocSortedHitQueue.java:118)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.search.controller.ShardFieldDocSortedHitQueue.lessThan(ShardFieldDocSortedHitQueue.java:35)
~[elasticsearch-0.90.3.jar:na]
at
org.apache.lucene.util.PriorityQueue.downHeap(PriorityQueue.java:247)
~[lucene-core-4.4.0.jar:4.4.0 1504776 - sarowe - 2013-07-19 02:53:42]
at org.apache.lucene.util.PriorityQueue.pop(PriorityQueue.java:184)
~[lucene-core-4.4.0.jar:4.4.0 1504776 - sarowe - 2013-07-19 02:53:42]
at
org.elasticsearch.search.controller.SearchPhaseController.sortDocs(SearchPhaseController.java:281)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.innerExecuteFetchPhase(TransportSearchDfsQueryThenFetchAction.java:177)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.executeFetchPhase(TransportSearchDfsQueryThenFetchAction.java:170)
~[elasticsearch-0.90.3.jar:na]
... 8 common frames omitted

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

To clarify: the whole query looks like that:

{
"query": {
"query_string": {
"query": "_parents.$id:5223195f93f46463974aa1f4"
}
},
"sort": [
{
"_subtype": {
"order": "desc",
"ignore_unmapped": true
}
},
{
"fileSize": {
"order": "asc",
"ignore_unmapped": true
}
}
]
}

The request is run against 2 indices. The _subtype field present for both
indices. The fileSize field is present for only one of them. Interesting
thing is that if I change fileSize field into some totally diffrerent
field, which is not present in any index, for example fileSizeAAA, I do not
get this error. If I omit one the _subtype field, and leave only fileSize
field, then I get another error:

{

  • error: ReduceSearchPhaseException[Failed to execute phase [query],
    [reduce] ]; nested: ClassCastException[org.apache.lucene.search.ScoreDoc
    cannot be cast to org.apache.lucene.search.FieldDoc];
  • status: 503

}

суббота, 31 августа 2013 г., 12:27:19 UTC+3 пользователь Alexei Petinov
написал:

This issue is experienced on version 0.90.3
Searching in two indexes with sort on two fields, for one of the indices
one of the fields is present, for another - it is not. 'ignore_unmapped' is
set to true for both of the fields.

"sort" : [
{
"_subtype": {
"order": "desc",
"ignore_unmapped": true
}
},
{
"fileSize": {
"order": "asc",
"ignore_unmapped": true
}
}
]

The result for JSON search is:

{
error: ReduceSearchPhaseException[Failed to execute phase [query],
[reduce] ]; nested: ArrayIndexOutOfBoundsException[1];
status: 500
}

When searchhing with Java API:

org.elasticsearch.action.search.ReduceSearchPhaseException: Failed to
execute phase [query], [reduce]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.executeFetchPhase(TransportSearchDfsQueryThenFetchAction.java:172)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction$3.onResult(TransportSearchDfsQueryThenFetchAction.java:150)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction$3.onResult(TransportSearchDfsQueryThenFetchAction.java:144)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:176)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.executeQuery(TransportSearchDfsQueryThenFetchAction.java:144)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction$2.run(TransportSearchDfsQueryThenFetchAction.java:131)
~[elasticsearch-0.90.3.jar:na]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
~[na:1.7.0_25]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
~[na:1.7.0_25]
at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at
org.elasticsearch.search.controller.ShardFieldDocSortedHitQueue.lessThan(ShardFieldDocSortedHitQueue.java:118)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.search.controller.ShardFieldDocSortedHitQueue.lessThan(ShardFieldDocSortedHitQueue.java:35)
~[elasticsearch-0.90.3.jar:na]
at
org.apache.lucene.util.PriorityQueue.downHeap(PriorityQueue.java:247)
~[lucene-core-4.4.0.jar:4.4.0 1504776 - sarowe - 2013-07-19 02:53:42]
at org.apache.lucene.util.PriorityQueue.pop(PriorityQueue.java:184)
~[lucene-core-4.4.0.jar:4.4.0 1504776 - sarowe - 2013-07-19 02:53:42]
at
org.elasticsearch.search.controller.SearchPhaseController.sortDocs(SearchPhaseController.java:281)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.innerExecuteFetchPhase(TransportSearchDfsQueryThenFetchAction.java:177)
~[elasticsearch-0.90.3.jar:na]
at
org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.executeFetchPhase(TransportSearchDfsQueryThenFetchAction.java:170)
~[elasticsearch-0.90.3.jar:na]
... 8 common frames omitted

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Just for information - it turns out there are limitations for using
ignore_unmapped field in cross-index queries. See response to the issue
here:
Error while sorting on fields which are not present for some of the documents · Issue #3599 · elastic/elasticsearch · GitHub

--
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.
For more options, visit https://groups.google.com/groups/opt_out.