diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java index 13e417dc0f0..7e331c9439f 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java @@ -242,7 +242,6 @@ public class TestIndexWriterMerging extends LuceneTestCase dir.close(); } - /* nocommit: Fix tests to use an id and delete by term // LUCENE-325: test forceMergeDeletes without waiting, when // many adjacent merges are required public void testForceMergeDeletes3() throws IOException { @@ -269,15 +268,27 @@ public class TestIndexWriterMerging extends LuceneTestCase document.add(storedField); Field termVectorField = newField("termVector", "termVector", customType1); document.add(termVectorField); - for(int i=0;i<98;i++) + Field idField = newField("id", "", StringField.TYPE_UNSTORED); + document.add(idField); + for(int i=0;i<98;i++) { + idField.setValue("" + i); writer.addDocument(document); + } writer.close(); IndexReader ir = IndexReader.open(dir); assertEquals(98, ir.maxDoc()); assertEquals(98, ir.numDocs()); - for(int i=0;i<98;i+=2) - ir.deleteDocument(i); + ir.close(); + + IndexWriterConfig dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)) + .setMergePolicy(NoMergePolicy.COMPOUND_FILES); + writer = new IndexWriter(dir, dontMergeConfig); + for(int i=0;i<98;i+=2) { + writer.deleteDocuments(new Term("id", "" + i)); + } + writer.close(); + ir = IndexReader.open(dir); assertEquals(49, ir.numDocs()); ir.close(); @@ -294,7 +305,6 @@ public class TestIndexWriterMerging extends LuceneTestCase ir.close(); dir.close(); } - */ // Just intercepts all merges & verifies that we are never // merging a segment with >= 20 (maxMergeDocs) docs