From 1ba9770037c29c41cd6ee306957842e00489c320 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Tue, 21 Feb 2017 18:18:44 +0100 Subject: [PATCH] Fix comparaison of double in InternalTopHits InternalTopHits uses "==" to compare hit scores and fails when score is NaN. This commit changes the comparaison to always use Double.compare. Relates #23253 --- .../search/aggregations/metrics/tophits/InternalTopHits.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java index 81216af23e7..de37e1a62d1 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java @@ -173,7 +173,7 @@ public class InternalTopHits extends InternalMetricsAggregation implements TopHi ScoreDoc thisDoc = topDocs.scoreDocs[d]; ScoreDoc otherDoc = other.topDocs.scoreDocs[d]; if (thisDoc.doc != otherDoc.doc) return false; - if (thisDoc.score != otherDoc.score) return false; + if (Double.compare(thisDoc.score, otherDoc.score) != 0) return false; if (thisDoc.shardIndex != otherDoc.shardIndex) return false; if (thisDoc instanceof FieldDoc) { if (false == (otherDoc instanceof FieldDoc)) return false;