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