From 99af41dd09a31dcae1ae96c70d750e2f31971170 Mon Sep 17 00:00:00 2001 From: Brian Woolfolk Date: Mon, 28 Oct 2024 10:20:18 -0700 Subject: [PATCH] Invalid skipper now preserves scorerSupplier optimization --- .../IndexSortSortedNumericDocValuesRangeQuery.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/search/IndexSortSortedNumericDocValuesRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/IndexSortSortedNumericDocValuesRangeQuery.java index 454242d25a4..8773d4bfb43 100644 --- a/lucene/core/src/java/org/apache/lucene/search/IndexSortSortedNumericDocValuesRangeQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/IndexSortSortedNumericDocValuesRangeQuery.java @@ -467,12 +467,14 @@ public class IndexSortSortedNumericDocValuesRangeQuery extends Query { DocValuesSkipper skipper = context.reader().getDocValuesSkipper(field); if (skipper != null) { if (skipper.minValue() > upperValue || skipper.maxValue() < lowerValue) { - return null; - } - if (skipper.docCount() == context.reader().maxDoc() - && skipper.minValue() >= lowerValue - && skipper.maxValue() <= upperValue) { - return IteratorAndCount.all(skipper.docCount()); + // Instead of returning null, act as there's no skipper. + skipper = null; + } else { + if (skipper.docCount() == context.reader().maxDoc() + && skipper.minValue() >= lowerValue + && skipper.maxValue() <= upperValue) { + return IteratorAndCount.all(skipper.docCount()); + } } }