Elasticsearch crashes on terms_stats query

On the following request elasticsearch crashes

curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{"query":{"bool":{"must":[{"query_string":
{"query":"notebook"}}]}},"facets":{"categories":{"terms_stats":
{"key_field":"category_id","value_script":"doc.score"}},"vendors":
{"terms_stats":
{"key_field":"vendor_id","value_script":"doc.score"}}},"size":10}'

{
"error" : "SearchPhaseExecutionException[Failed to execute phase
[query_fetch], total failure; shardFailures
{IllegalArgumentException[Comparison method violates its general
contract!]}]",
"status" : 500
}

Trace:

java.lang.IllegalArgumentException: Comparison method violates its
general contract!
at java.util.TimSort.mergeLo(TimSort.java:747)
at java.util.TimSort.mergeAt(TimSort.java:483)
at java.util.TimSort.mergeCollapse(TimSort.java:410)
at java.util.TimSort.sort(TimSort.java:214)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at
org.elasticsearch.search.facet.termsstats.longs.TermsStatsLongFacetCollector.facet(TermsStatsLongFacetCollector.java:
139)
at org.elasticsearch.search.facet.FacetPhase.execute(FacetPhase.java:
139)
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:
226)
at
org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:
312)
at
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:
224)
at
org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction
$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:
71)
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:
1110)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

Can you open an issue with a curl recreation? (Elasticsearch Platform — Find real-time answers at scale | Elastic).

On Thursday, January 26, 2012 at 6:59 PM, Ash wrote:

On the following request elasticsearch crashes

curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{"query":{"bool":{"must":[{"query_string":
{"query":"notebook"}}]}},"facets":{"categories":{"terms_stats":
{"key_field":"category_id","value_script":"doc.score"}},"vendors":
{"terms_stats":
{"key_field":"vendor_id","value_script":"doc.score"}}},"size":10}'

{
"error" : "SearchPhaseExecutionException[Failed to execute phase
[query_fetch], total failure; shardFailures
{IllegalArgumentException[Comparison method violates its general
contract!]}]",
"status" : 500
}

Trace:

java.lang.IllegalArgumentException: Comparison method violates its
general contract!
at java.util.TimSort.mergeLo(TimSort.java:747)
at java.util.TimSort.mergeAt(TimSort.java:483)
at java.util.TimSort.mergeCollapse(TimSort.java:410)
at java.util.TimSort.sort(TimSort.java:214)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at
org.elasticsearch.search.facet.termsstats.longs.TermsStatsLongFacetCollector.facet(TermsStatsLongFacetCollector.java:
139)
at org.elasticsearch.search.facet.FacetPhase.execute(FacetPhase.java:
139)
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:
226)
at
org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:
312)
at
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:
224)
at
org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction
$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:
71)
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:
1110)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)