martijnvg commented on code in PR #15741:
URL: https://github.com/apache/lucene/pull/15741#discussion_r2834277480
##########
lucene/core/src/test/org/apache/lucene/search/TestSortOptimization.java:
##########
@@ -1071,6 +1071,100 @@ private void
testStringSortOptimizationWithMissingValues(
dir.close();
}
+ public void testStringSortOptimizationFieldMissingInSegmentBasedPostings()
throws IOException {
+ testStringSortOptimizationFieldMissingInSegment(
+ (field, value) -> new KeywordField(field, value, Field.Store.NO));
+ }
+
+ public void testStringSortOptimizationFieldMissingInSegmentBasedDVSkipper()
throws IOException {
+
testStringSortOptimizationFieldMissingInSegment(SortedDocValuesField::indexedField);
+ }
+
+ /**
+ * Test that when a segment doesn't contain the sort field at all (fieldInfo
== null), the
+ * optimization still works. All docs in such a segment have missing values,
and when missing
+ * values are non-competitive the entire segment should be skippable.
+ */
+ private void testStringSortOptimizationFieldMissingInSegment(
+ BiFunction<String, BytesRef, IndexableField> fieldsBuilder) throws
IOException {
+ final Directory dir = newDirectory();
+ final IndexWriter writer =
+ new IndexWriter(dir, new
IndexWriterConfig().setMergePolicy(newLogMergePolicy()));
Review Comment:
I wonder whether this merge policy is good enough for this test case, so
that we don't have rare runs where we somehow don't have an empty segment?
I think the `atLeast(10000)` should cover this in line 1105? But maybe
there is a better way to enforce this. Like using the no merge policy?
--
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]