martijnvg commented on code in PR #15397:
URL: https://github.com/apache/lucene/pull/15397#discussion_r2490028541
##########
lucene/core/src/java/org/apache/lucene/search/comparators/NumericComparator.java:
##########
@@ -364,6 +366,25 @@ int docCount() {
return pointValues.getDocCount();
}
+ /**
+ * If queue is full and global min/max point values are not competitive
with bottom then set an
+ * empty iterator as competitive iterator.
+ *
+ * @throws IOException i/o exception while fetching min and max values
from point values
+ */
+ void postInitializeCompetitiveIterator() throws IOException {
+ if (queueFull) {
+ long bottom = leafComparator.bottomAsComparableLong();
+ long minValue = sortableBytesToLong(pointValues.getMinPackedValue());
Review Comment:
Good point, we still need it. Otherwise we would incorrectly ignore the docs
with missing values is missing sort value is competitive. I pushed this
commit: 2df7908e1523d3ddea581c2bc42e4db5ad5e6992
I also added a test for this case. The `TestSortOptimization` test suite
didn't catch this problem also after running it for thousands of times . I
think this is because in the test, a document without a field is encountered
before the queue is full and then bottom is not competitive with missing value.
--
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]