From 1ce1156de441ff5be17b3f83f781faf10c774537 Mon Sep 17 00:00:00 2001 From: Jakub Slowinski <32519034+slow-J@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:03:09 +0100 Subject: [PATCH] Fix failing unit test - TestTopDocsCollector#testResultsOrder (#13621) --- .../test/org/apache/lucene/search/TestTopDocsCollector.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/search/TestTopDocsCollector.java b/lucene/core/src/test/org/apache/lucene/search/TestTopDocsCollector.java index 0566061f357..e91858800a2 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestTopDocsCollector.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestTopDocsCollector.java @@ -72,9 +72,6 @@ public class TestTopDocsCollector extends LuceneTestCase { } private static final class MyTopDocsCollector extends TopDocsCollector { - - private int idx = 0; - public MyTopDocsCollector(int size) { super(new HitQueue(size, false)); } @@ -92,11 +89,12 @@ public class TestTopDocsCollector extends LuceneTestCase { public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException { final int base = context.docBase; return new LeafCollector() { + private int idx = 0; @Override public void collect(int doc) { ++totalHits; - pq.insertWithOverflow(new ScoreDoc(doc + base, scores[idx++])); + pq.insertWithOverflow(new ScoreDoc(doc + base, scores[context.docBase + idx++])); } @Override