LUCENE-9662: fix test failure from merging away soft-deletes (#276)

This commit is contained in:
zacharymorn 2021-09-01 22:18:29 -07:00 committed by GitHub
parent ee7a719dd8
commit 34232430f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -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();