serhiy-bzhezytskyy commented on PR #16411: URL: https://github.com/apache/lucene/pull/16411#issuecomment-5160180762
Both of Mike's cases turned out to be worth chasing, and one of them was a real gap. **Single value for every document** — already optimized: the field is dense, so `minOrd = 0` and `maxOrd = bottomOrd - 1` give an empty range. The suite only had that case for numeric fields (`testSortOptimizationEqualValues*`), never for strings, so I added a test rather than code. **All docs in the queue missing, sorting missing first** — not optimized at all. A test on that case collects every document: `collected_hits=14354 num_docs=14354`. `shouldEnableSkipping` returns false whenever missing values sort best, on the grounds that "missing values are always competitive, we can never skip" — which holds only while the queue has room. With no tie breaker, once it is full of missing values a further one cannot displace any of them. Gated on `singleSort`, so a sort with a tie breaker is unchanged. Worth noting that enabling skipping unconditionally there also passes the suite, because `updateCompetitiveIterator` still decides when the range is safe. The `singleSort` guard states the intent rather than carrying the correctness. On `#16424`: `Sort.getPrimarySortField` is about the index sort and is called only from the DV range queries, so it doesn't reach this path, which is the search sort. -- 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]
