jpountz commented on code in PR #12415: URL: https://github.com/apache/lucene/pull/12415#discussion_r1276566623
########## lucene/test-framework/src/java/org/apache/lucene/tests/search/QueryUtils.java: ########## @@ -738,4 +740,66 @@ public void collect(int doc) throws IOException { } } } + + /** + * Check that counting hits through {@link DocIdStream#count()} yield the same result as counting + * naively. + */ + public static void checkCount(Query query, final IndexSearcher searcher) throws IOException { + query = searcher.rewrite(query); + Weight weight = searcher.createWeight(query, ScoreMode.COMPLETE_NO_SCORES, 1); + for (LeafReaderContext context : searcher.getIndexReader().leaves()) { + BulkScorer scorer = weight.bulkScorer(context); + if (scorer == null) { + continue; + } + int[] expectedCount = {0}; + boolean[] docIdStream = {false}; + scorer.score( + new LeafCollector() { + @Override + public void collect(DocIdStream stream) throws IOException { + docIdStream[0] = true; + LeafCollector.super.collect(stream); Review Comment: Correct -- 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