Don't use PointValues stats for doc-values range rewrite - #16575
Open
kalayciburak wants to merge 1 commit into
Open
Don't use PointValues stats for doc-values range rewrite#16575kalayciburak wants to merge 1 commit into
kalayciburak wants to merge 1 commit into
Conversation
SortedNumericDocValuesRangeQuery.rewrite consulted NumericFieldStats.getStats, which prefers PointValues. Point encodings can differ from doc-values (for example DoublePoint vs Double.doubleToLongBits), so a valid range was rewritten to MatchNoDocsQuery. Use skipper stats only.
kalayciburak
force-pushed
the
fix/16573-docvalues-range-point-stats
branch
from
August 28, 2026 16:56
4bb593f to
8498423
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SortedNumericDocValuesRangeQuery.rewriteusedNumericFieldStats.getStats, which prefersPointValues. Point encodings can differ from doc-values (for exampleDoublePointvsDouble.doubleToLongBitsonNumericDocValuesField), so a valid doc-values range was rewritten toMatchNoDocsQuery.IndexOrDocValuesQuerythen dropped the hits as well.This rewrite now uses skipper-only stats. When no skipper is present, the min/max optimization is skipped and the query runs against the actual doc-values.
Fixes #16573
Tests
./gradlew :lucene:core:test --tests org.apache.lucene.document.TestSortedNumericDocValuesRangeQuery --tests org.apache.lucene.search.TestNumericFieldStats --tests org.apache.lucene.search.TestIndexSortSortedNumericDocValuesRangeQuery --tests org.apache.lucene.document.TestDoubleRange --tests org.apache.lucene.document.TestFloatRange(44 tests)./gradlew :lucene:sandbox:test --tests org.apache.lucene.sandbox.document.TestHalfFloatPoint.testNumericFieldStats(1 test)