jpountz commented on code in PR #15080: URL: https://github.com/apache/lucene/pull/15080#discussion_r2279915982
########## lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesRangeQuery.java: ########## @@ -184,6 +184,25 @@ public float matchCost() { return ConstantScoreScorerSupplier.fromIterator( TwoPhaseIterator.asDocIdSetIterator(iterator), score(), scoreMode, maxDoc); } + + @Override + public int count(LeafReaderContext context) throws IOException { + DocValuesSkipper skipper = context.reader().getDocValuesSkipper(field); + if (skipper == null) { + return -1; + } + if (skipper.minValue() > upperValue || skipper.maxValue() < lowerValue) { + return 0; + } + if (skipper.docCount() == context.reader().maxDoc() + && context.reader().hasDeletions() == false + && skipper.minValue() >= lowerValue + && skipper.maxValue() <= upperValue) { + + return context.reader().maxDoc(); Review Comment: You could make it slightly more general by removing the check on `hasDeletions()` and returning `context.reader().numDocs()`. -- 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