From 6e3264d185cd1308e5bef5592952e1a76c9a2de3 Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Fri, 29 Dec 2023 13:21:37 -0800 Subject: [PATCH] Extend error message, fix typo in class name Signed-off-by: Martin Gaievski --- .../processor/NormalizationProcessorWorkflow.java | 7 ++++++- ...oldCheckerTests.java => HitsThresholdCheckerTests.java} | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) rename src/test/java/org/opensearch/neuralsearch/search/{HitsTresholdCheckerTests.java => HitsThresholdCheckerTests.java} (87%) diff --git a/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessorWorkflow.java b/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessorWorkflow.java index 71daeac35..c322102d5 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessorWorkflow.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessorWorkflow.java @@ -180,7 +180,12 @@ private SearchHit[] getSearchHits(final List docIds, final FetchSearchR } if (searchHitArray.length != docIds.size()) { throw new IllegalStateException( - "score normalization processor cannot produce final query result, the number of documents returned by fetch and query phases does not match" + String.format( + Locale.ROOT, + "score normalization processor cannot produce final query result, the number of documents after fetch phase [%d] is different from number of documents from query phase [%d]", + searchHitArray.length, + docIds.size() + ) ); } return searchHitArray; diff --git a/src/test/java/org/opensearch/neuralsearch/search/HitsTresholdCheckerTests.java b/src/test/java/org/opensearch/neuralsearch/search/HitsThresholdCheckerTests.java similarity index 87% rename from src/test/java/org/opensearch/neuralsearch/search/HitsTresholdCheckerTests.java rename to src/test/java/org/opensearch/neuralsearch/search/HitsThresholdCheckerTests.java index df1198232..3ce9e3dfe 100644 --- a/src/test/java/org/opensearch/neuralsearch/search/HitsTresholdCheckerTests.java +++ b/src/test/java/org/opensearch/neuralsearch/search/HitsThresholdCheckerTests.java @@ -10,9 +10,9 @@ import org.apache.lucene.search.ScoreMode; import org.opensearch.neuralsearch.query.OpenSearchQueryTestCase; -public class HitsTresholdCheckerTests extends OpenSearchQueryTestCase { +public class HitsThresholdCheckerTests extends OpenSearchQueryTestCase { - public void testTresholdReached_whenIncrementCount_thenTresholdReached() { + public void testThresholdReached_whenIncrementCount_thenThresholdReached() { HitsThresholdChecker hitsThresholdChecker = new HitsThresholdChecker(5); assertEquals(5, hitsThresholdChecker.getTotalHitsThreshold()); assertEquals(ScoreMode.TOP_SCORES, hitsThresholdChecker.scoreMode()); @@ -23,7 +23,7 @@ public void testTresholdReached_whenIncrementCount_thenTresholdReached() { assertTrue(hitsThresholdChecker.isThresholdReached()); } - public void testTresholdLimit_whenThresholdNegative_thenFail() { + public void testThresholdLimit_whenThresholdNegative_thenFail() { expectThrows(IllegalArgumentException.class, () -> new HitsThresholdChecker(-1)); }