From a7d0bbe0239be79a18b790d1bbe66e3e2ea602de Mon Sep 17 00:00:00 2001 From: Bo Zhang Date: Wed, 18 Dec 2024 12:52:25 -0800 Subject: [PATCH] Fix random total hits range for ExplanationPayloadProcessorTests. (#1034) Signed-off-by: Bo Zhang (cherry picked from commit 22ba5d3c72eb7b2fc510a2ed4c02a1b0a70dd271) --- .../processor/ExplanationPayloadProcessorTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/opensearch/neuralsearch/processor/ExplanationPayloadProcessorTests.java b/src/test/java/org/opensearch/neuralsearch/processor/ExplanationPayloadProcessorTests.java index e47ea43d2..2e603d078 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/ExplanationPayloadProcessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/ExplanationPayloadProcessorTests.java @@ -125,7 +125,7 @@ public void testParsingOfExplanations_whenFieldSortingAndExplanations_thenSucces searchHit.explanation(explanation); } TotalHits.Relation totalHitsRelation = randomFrom(TotalHits.Relation.values()); - TotalHits totalHits = new TotalHits(randomLongBetween(0, 1000), totalHitsRelation); + TotalHits totalHits = new TotalHits(randomLongBetween(1, 1000), totalHitsRelation); final SortField[] sortFields = new SortField[] { new SortField("random-text-field-1", SortField.Type.INT, randomBoolean()), new SortField("random-text-field-2", SortField.Type.STRING, randomBoolean()) }; @@ -203,7 +203,7 @@ private static SearchHits getSearchHits(float maxScore) { int requestedSize = 2; PriorityQueue priorityQueue = new PriorityQueue<>(new SearchHitComparator(null)); TotalHits.Relation totalHitsRelation = randomFrom(TotalHits.Relation.values()); - TotalHits totalHits = new TotalHits(randomLongBetween(0, 1000), totalHitsRelation); + TotalHits totalHits = new TotalHits(randomLongBetween(1, 1000), totalHitsRelation); final int numDocs = totalHits.value >= requestedSize ? requestedSize : (int) totalHits.value; int scoreFactor = randomIntBetween(1, numResponses);