From 60c46f3a6c33b1c1074f161b629927e5d60917c0 Mon Sep 17 00:00:00 2001 From: Jay Deng Date: Sun, 19 Nov 2023 17:56:45 -0800 Subject: [PATCH] Fix maxScore check in reduce phase when some scores are NaN (#11267) Signed-off-by: Jay Deng --- .../java/org/opensearch/search/sort/FieldSortIT.java | 4 ---- .../org/opensearch/search/query/TopDocsCollectorContext.java | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java index 3c5574f823c3b..81e948640ee94 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java @@ -268,10 +268,6 @@ public void testIssue6614() throws ExecutionException, InterruptedException { } public void testTrackScores() throws Exception { - assumeFalse( - "Concurrent search case muted pending fix: https://github.com/opensearch-project/OpenSearch/issues/11189", - internalCluster().clusterService().getClusterSettings().get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING) - ); assertAcked(client().admin().indices().prepareCreate("test").setMapping("svalue", "type=keyword").get()); ensureGreen(); index( diff --git a/server/src/main/java/org/opensearch/search/query/TopDocsCollectorContext.java b/server/src/main/java/org/opensearch/search/query/TopDocsCollectorContext.java index 86f6e542f97d1..65d3948c8401e 100644 --- a/server/src/main/java/org/opensearch/search/query/TopDocsCollectorContext.java +++ b/server/src/main/java/org/opensearch/search/query/TopDocsCollectorContext.java @@ -532,7 +532,7 @@ public ReduceableSearchResult reduce(Collection collectors) throws IO float score = collector.getMaxScore(); if (Float.isNaN(maxScore)) { maxScore = score; - } else { + } else if (!Float.isNaN(score)) { maxScore = Math.max(maxScore, score); } }