|
21 | 21 | import org.apache.lucene.analysis.CannedTokenStream;
|
22 | 22 | import org.apache.lucene.analysis.Token;
|
23 | 23 | import org.apache.lucene.document.*;
|
| 24 | +import org.apache.lucene.search.MatchAllDocsQuery; |
24 | 25 | import org.apache.lucene.search.Sort;
|
25 | 26 | import org.apache.lucene.search.SortField;
|
26 | 27 | import org.apache.lucene.store.Directory;
|
@@ -70,10 +71,14 @@ public void testObtainsLock() throws IOException {
|
70 | 71 | public void testCheckIndexAllValid() throws Exception {
|
71 | 72 | try (Directory dir = newDirectory()) {
|
72 | 73 | int liveDocCount = 1 + random().nextInt(10);
|
73 |
| - IndexWriterConfig conifg = newIndexWriterConfig(); |
74 |
| - conifg.setIndexSort(new Sort(new SortField("sort_field", SortField.Type.INT, true))); |
75 |
| - conifg.setSoftDeletesField("soft_delete"); |
76 |
| - try (IndexWriter w = new IndexWriter(dir, conifg)) { |
| 74 | + IndexWriterConfig config = newIndexWriterConfig(); |
| 75 | + config.setIndexSort(new Sort(new SortField("sort_field", SortField.Type.INT, true))); |
| 76 | + config.setSoftDeletesField("soft_delete"); |
| 77 | + // preserves soft-deletes across merges |
| 78 | + config.setMergePolicy( |
| 79 | + new SoftDeletesRetentionMergePolicy( |
| 80 | + "soft_delete", MatchAllDocsQuery::new, config.getMergePolicy())); |
| 81 | + try (IndexWriter w = new IndexWriter(dir, config)) { |
77 | 82 | for (int i = 0; i < liveDocCount; i++) {
|
78 | 83 | Document doc = new Document();
|
79 | 84 |
|
|
0 commit comments