Apache Lucene open-source search software
LUCENE-9662: fix test failure from merging away soft-deletes (#276)
zacharymorn34232430f200
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java b/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.javaindex 2d0fb8e3d31..93658d6a6de 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java@@ -21,6 +21,7 @@ import java.io.IOException;import org.apache.lucene.analysis.CannedTokenStream;import org.apache.lucene.analysis.Token;import org.apache.lucene.document.*;+import org.apache.lucene.search.MatchAllDocsQuery;import org.apache.lucene.search.Sort;import org.apache.lucene.search.SortField;import org.apache.lucene.store.Directory;@@ -70,10 +71,14 @@ public class TestCheckIndex extends BaseTestCheckIndex {public void testCheckIndexAllValid() throws Exception {try (Directory dir = newDirectory()) {int liveDocCount = 1 + random().nextInt(10);- IndexWriterConfig conifg = newIndexWriterConfig();- conifg.setIndexSort(new Sort(new SortField("sort_field", SortField.Type.INT, true)));- conifg.setSoftDeletesField("soft_delete");- try (IndexWriter w = new IndexWriter(dir, conifg)) {+ IndexWriterConfig config = newIndexWriterConfig();+ config.setIndexSort(new Sort(new SortField("sort_field", SortField.Type.INT, true)));+ config.setSoftDeletesField("soft_delete");+ // preserves soft-deletes across merges+ config.setMergePolicy(+ new SoftDeletesRetentionMergePolicy(+ "soft_delete", MatchAllDocsQuery::new, config.getMergePolicy()));+ try (IndexWriter w = new IndexWriter(dir, config)) {for (int i = 0; i < liveDocCount; i++) {Document doc = new Document();