From caf55e0e798674715c775d5d1ff9138424a71307 Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Mon, 6 Mar 2023 15:29:36 +0000 Subject: [PATCH] GITHUB-12181: fix false-positive TestKnnFloatVectorQuery.testDocAndScoreQueryBasics() failure (#12182) (cherry picked from commit 3bd06b1cb94fe8ca9e198463a7e1b9dc68316fa3) Resolved Conflicts: lucene/core/src/test/org/apache/lucene/search/TestKnnFloatVectorQuery.java --- .../org/apache/lucene/search/TestKnnFloatVectorQuery.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/search/TestKnnFloatVectorQuery.java b/lucene/core/src/test/org/apache/lucene/search/TestKnnFloatVectorQuery.java index ea26278c64f3..684e260f12b7 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestKnnFloatVectorQuery.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestKnnFloatVectorQuery.java @@ -196,11 +196,12 @@ public void testDocAndScoreQueryBasics() throws IOException { scores[i] = scoreDocs[i].score; maxScore = Math.max(maxScore, scores[i]); } - int[] segments = AbstractKnnVectorQuery.findSegmentStarts(reader, docs); + IndexReader indexReader = searcher.getIndexReader(); + int[] segments = AbstractKnnVectorQuery.findSegmentStarts(indexReader, docs); AbstractKnnVectorQuery.DocAndScoreQuery query = new AbstractKnnVectorQuery.DocAndScoreQuery( - scoreDocs.length, docs, scores, segments, reader.getContext().id()); + scoreDocs.length, docs, scores, segments, indexReader.getContext().id()); final Weight w = query.createWeight(searcher, ScoreMode.TOP_SCORES, 1.0f); TopDocs topDocs = searcher.search(query, 100); assertEquals(scoreDocs.length, topDocs.totalHits.value);