serhiy-bzhezytskyy commented on code in PR #16434:
URL: https://github.com/apache/lucene/pull/16434#discussion_r3683230960
##########
lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java:
##########
@@ -45,20 +45,18 @@ private abstract class TopFieldLeafCollector implements
LeafCollector {
final LeafFieldComparator comparator;
final int reverseMul;
+ // Whether the search sort is a prefix of this segment's index sort
(decided per segment).
+ final boolean searchSortPartOfIndexSort;
Scorable scorer;
boolean collectedAllCompetitiveHits = false;
TopFieldLeafCollector(FieldValueHitQueue<Entry> queue, Sort sort,
LeafReaderContext context)
throws IOException {
- // as all segments are sorted in the same way, enough to check only the
1st segment for
- // indexSort
- if (searchSortPartOfIndexSort == null) {
- final Sort indexSort = context.reader().getMetaData().sort();
- searchSortPartOfIndexSort = canEarlyTerminate(sort, indexSort);
- if (searchSortPartOfIndexSort) {
- firstComparator.disableSkipping();
- }
- }
+ // Whether the search sort is a prefix of the index sort is decided per
segment: a MultiReader
+ // may combine segments with different index sorts, so this cannot be
cached across leaves
+ // (GITHUB#14399).
+ final Sort indexSort = context.reader().getMetaData().sort();
Review Comment:
Agreed on leaving it for a follow-up. `canEarlyTerminate` compares the full
prefix, so a primary-field shortcut would have to keep the same answer for
multi-field sorts — worth its own change with its own tests.
--
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]