kkewwei opened a new issue, #16980: URL: https://github.com/apache/lucene/issues/16980
### Description `TermOrdValComparator` requires the hit queue to be full before updating its competitive iterator. For search_after query, this means that docs before the page boundary may still be visited and compared one by one, even though the search_after value already provides a usable sorting bound. https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java#L418 `NumericComparator` already supports this case: when a top value is set, it builds competitive range before the queue is full, and adds the bottom bound once the queue becomes full. https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/comparators/NumericComparator.java#L226 Align term sorting with this numeric sort behavior. Before the queue is full, use the segment-local ordinal of the search_after value to build a competitive range: * ascending: [topOrd, lastOrd] * descending: [firstOrd, topOrd] This optimization is particularly effective for deep pagination with`search_after` , as it can quickly prune irrelevant terms. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
