Skip to content

Don't use PointValues stats for doc-values range rewrite - #16575

Open
kalayciburak wants to merge 1 commit into
apache:mainfrom
kalayciburak:fix/16573-docvalues-range-point-stats
Open

Don't use PointValues stats for doc-values range rewrite#16575
kalayciburak wants to merge 1 commit into
apache:mainfrom
kalayciburak:fix/16573-docvalues-range-point-stats

Conversation

@kalayciburak

Copy link
Copy Markdown

Description

SortedNumericDocValuesRangeQuery.rewrite used NumericFieldStats.getStats, which prefers PointValues. Point encodings can differ from doc-values (for example DoublePoint vs Double.doubleToLongBits on NumericDocValuesField), so a valid doc-values range was rewritten to MatchNoDocsQuery. IndexOrDocValuesQuery then 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)

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
kalayciburak force-pushed the fix/16573-docvalues-range-point-stats branch from 4bb593f to 8498423 Compare August 28, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

incorrect results from SortedNumericDocValuesRangeQuery when using double/float based points+NumericDocValuesField

1 participant