jpountz commented on issue #14517: URL: https://github.com/apache/lucene/issues/14517#issuecomment-2816267241
You are correct. Here is the simplest recreation of the bug I could come up with: ```java Directory dir = new ByteBuffersDirectory(); IndexWriter w = new IndexWriter(dir, new IndexWriterConfig()); // high max doc to have a high number of unique values so that the competitive iterator is // initialized with `docsWithField` rather than specific (< 1024) terms int maxDoc = 5_000; for (int i = 0; i < maxDoc; ++i) { Document doc = new Document(); // We need the field to be sparse, so that the competitive iterator is initialized with // `docsWithField` if (i % 2 == 0) { doc.add(new StringField("field", "value", Store.NO)); doc.add(new KeywordField("sort", Integer.toString(i), Store.NO)); } w.addDocument(doc); } w.forceMerge(1); w.close(); DirectoryReader reader = DirectoryReader.open(dir); LeafReaderContext context = reader.leaves().get(0); IndexSearcher searcher = new IndexSearcher(reader); Query query = new TermQuery(new Term("field", "value")); Weight weight = searcher.createWeight(query, ScoreMode.COMPLETE_NO_SCORES, RANDOM_MULTIPLIER); SortField sortField = KeywordField.newSortField("sort", false, SortedSetSelector.Type.MIN); sortField.setMissingValue(SortField.STRING_LAST); Sort sort = new Sort(sortField); Collector collector = new TopFieldCollectorManager(sort, 10, 10).newCollector(); LeafCollector leafCollector = collector.getLeafCollector(context); BulkScorer bulkScorer = weight.bulkScorer(context); // We need to split on this specific doc ID so that the current doc of the competitive iterator // and the current doc of `docsWithField` are out of sync, because the competitive iterator was // just updated. bulkScorer.score(leafCollector, null, 0, 22); bulkScorer.score(leafCollector, null, 22, maxDoc); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org