jpountz commented on code in PR #14609: URL: https://github.com/apache/lucene/pull/14609#discussion_r2081563312
########## lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java: ########## @@ -580,4 +534,114 @@ public final String toString(String field) { * @return human readable value for debugging */ protected abstract String toString(int dimension, byte[] value); + + @Override + public Query rewrite(IndexSearcher searcher) throws IOException { + IndexReader reader = searcher.getIndexReader(); + + for (LeafReaderContext leaf : reader.leaves()) { + checkValidPointValues(leaf.reader().getPointValues(field)); + } + + // fetch the global min/max packed values across all segments + byte[] globalMinPacked = PointValues.getMinPackedValue(reader, getField()); + byte[] globalMaxPacked = PointValues.getMaxPackedValue(reader, getField()); + + if (globalMinPacked == null || globalMaxPacked == null) { + return super.rewrite(searcher); Review Comment: A null min or max packed value indicates an empty field, so you could rewrite to a `MatchNoDocsQuery` here as well. -- 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