Skip to content

Comments

Add FieldMinMax unified API for global numeric min/max retrieval#15752

Open
SYEDMDSAAD wants to merge 2 commits intoapache:mainfrom
SYEDMDSAAD:field-minmax-api
Open

Add FieldMinMax unified API for global numeric min/max retrieval#15752
SYEDMDSAAD wants to merge 2 commits intoapache:mainfrom
SYEDMDSAAD:field-minmax-api

Conversation

@SYEDMDSAAD
Copy link
Contributor

This patch introduces FieldMinMax, a unified API to retrieve global
minimum and maximum numeric values for a field across an IndexReader.

Currently Lucene exposes two different mechanisms:

  • PointValues.getMinPackedValue / getMaxPackedValue

    • returns null when no values exist
  • DocValuesSkipper.globalMinValue / globalMaxValue

    • returns sentinel values when metadata is unavailable

This forces callers to understand internal storage details and manually filter invalid values.

FieldMinMax abstracts over both implementations and provides consistent behavior:

  • Uses PointValues when available (accurate index statistics)
  • Falls back to DocValuesSkipper when metadata exists
  • Falls back to scanning NumericDocValues when skipper metadata is absent
  • Returns null when no values exist

This prevents sentinel leakage and simplifies caller logic.

Tests cover:

  • missing field
  • point values
  • doc values
  • mixed segments
  • empty segments

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.

1 participant