romseygeek commented on code in PR #15741:
URL: https://github.com/apache/lucene/pull/15741#discussion_r2834335250
##########
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:
We create one segment with 20 docs that have the value, then flush, and then
add a whole bunch of documents with no values. I don't think it would be
possible to get no segments that have no values? Unless it decided to merge
everything down to a single segment, I suppose. Yeah, ok, maybe a
NoMergePolicy is better here if we need a deterministic index geometry.
--
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]