public virtual void TestForceMergeDeletesMaxSegSize() { Directory dir = NewDirectory(); IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)); TieredMergePolicy tmp = new TieredMergePolicy(); tmp.MaxMergedSegmentMB = 0.01; tmp.ForceMergeDeletesPctAllowed = 0.0; conf.SetMergePolicy(tmp); RandomIndexWriter w = new RandomIndexWriter(Random, dir, conf); w.DoRandomForceMerge = false; int numDocs = AtLeast(200); for (int i = 0; i < numDocs; i++) { Document doc = new Document(); doc.Add(NewStringField("id", "" + i, Field.Store.NO)); doc.Add(NewTextField("content", "aaa " + i, Field.Store.NO)); w.AddDocument(doc); } w.ForceMerge(1); IndexReader r = w.GetReader(); Assert.AreEqual(numDocs, r.MaxDoc); Assert.AreEqual(numDocs, r.NumDocs); r.Dispose(); if (VERBOSE) { Console.WriteLine("\nTEST: delete doc"); } w.DeleteDocuments(new Term("id", "" + (42 + 17))); r = w.GetReader(); Assert.AreEqual(numDocs, r.MaxDoc); Assert.AreEqual(numDocs - 1, r.NumDocs); r.Dispose(); w.ForceMergeDeletes(); r = w.GetReader(); Assert.AreEqual(numDocs - 1, r.MaxDoc); Assert.AreEqual(numDocs - 1, r.NumDocs); r.Dispose(); w.Dispose(); dir.Dispose(); }