Add FieldMinMax unified API for global numeric min/max retrieval#15752
Add FieldMinMax unified API for global numeric min/max retrieval#15752SYEDMDSAAD wants to merge 2 commits intoapache:mainfrom
Conversation
f879b41 to
625df71
Compare
625df71 to
ac19825
Compare
|
@SYEDMDSAAD trying to understand the motivation behind this API in Lucene specifically? Why this cannot be added in your application side? |
@navneet1v Thanks for the question. The motivation is mainly consistency. Right now, Lucene exposes two different APIs for global min/max, and they behave differently when no data exists — one returns null, the other returns sentinel values. That forces callers to know internal details and handle edge cases themselves. While this can be implemented on the application side, the logic depends on Lucene-specific behavior (like skipper availability and sentinel semantics). Centralizing it in Lucene provides a single, consistent contract and avoids duplication and potential mistakes in user code. So the idea is to normalize existing Lucene behavior, not just add convenience. |
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
DocValuesSkipper.globalMinValue / globalMaxValue
This forces callers to understand internal storage details and manually filter invalid values.
FieldMinMax abstracts over both implementations and provides consistent behavior:
This prevents sentinel leakage and simplifies caller logic.
Tests cover: