lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r921480 [5/8] - in /lucene/java/trunk: ./ contrib/analyzers/common/src/test/org/apache/lucene/analysis/query/ contrib/analyzers/common/src/test/org/apache/lucene/analysis/shingle/ contrib/ant/src/java/org/apache/lucene/ant/ contrib/benchmar...
Date Wed, 10 Mar 2010 17:53:51 GMT
Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=921480&r1=921479&r2=921480&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java Wed Mar 10 17:53:46 2010
@@ -35,7 +35,6 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.CachingTokenFilter;
-import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.analysis.StopAnalyzer;
 import org.apache.lucene.analysis.TeeSinkTokenFilter;
 import org.apache.lucene.analysis.TokenFilter;
@@ -49,6 +48,10 @@ import org.apache.lucene.analysis.tokena
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.document.Field.Index;
+import org.apache.lucene.document.Field.Store;
+import org.apache.lucene.document.Field.TermVector;
+import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.PhraseQuery;
 import org.apache.lucene.search.Query;
@@ -74,23 +77,20 @@ public class TestIndexWriter extends Luc
       super(name);
     }
 
-    public void testDocCount() throws IOException
-    {
+    public void testDocCount() throws IOException {
         Directory dir = new RAMDirectory();
 
         IndexWriter writer = null;
         IndexReader reader = null;
         int i;
 
-        long savedWriteLockTimeout = IndexWriter.getDefaultWriteLockTimeout();
+        long savedWriteLockTimeout = IndexWriterConfig.getDefaultWriteLockTimeout();
         try {
-          IndexWriter.setDefaultWriteLockTimeout(2000);
-          assertEquals(2000, IndexWriter.getDefaultWriteLockTimeout());
-
-          writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-
+          IndexWriterConfig.setDefaultWriteLockTimeout(2000);
+          assertEquals(2000, IndexWriterConfig.getDefaultWriteLockTimeout());
+          writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
         } finally {
-          IndexWriter.setDefaultWriteLockTimeout(savedWriteLockTimeout);
+          IndexWriterConfig.setDefaultWriteLockTimeout(savedWriteLockTimeout);
         }
 
         // add 100 documents
@@ -108,7 +108,7 @@ public class TestIndexWriter extends Luc
         reader.close();
 
         // test doc count before segments are merged/index is optimized
-        writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+        writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
         assertEquals(100, writer.maxDoc());
         writer.close();
 
@@ -118,7 +118,7 @@ public class TestIndexWriter extends Luc
         reader.close();
 
         // optimize the index and check that the new doc count is correct
-        writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
+        writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
         assertEquals(100, writer.maxDoc());
         assertEquals(60, writer.numDocs());
         writer.optimize();
@@ -134,7 +134,7 @@ public class TestIndexWriter extends Luc
 
         // make sure opening a new index for create over
         // this existing one works correctly:
-        writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+        writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setOpenMode(OpenMode.CREATE));
         assertEquals(0, writer.maxDoc());
         assertEquals(0, writer.numDocs());
         writer.close();
@@ -177,7 +177,7 @@ public class TestIndexWriter extends Luc
       long inputDiskUsage = 0;
       for(int i=0;i<NUM_DIR;i++) {
         dirs[i] = new RAMDirectory();
-        IndexWriter writer  = new IndexWriter(dirs[i], new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+        IndexWriter writer  = new IndexWriter(dirs[i], new IndexWriterConfig(TEST_VERSION_CURRENT));
         for(int j=0;j<25;j++) {
           addDocWithIndex(writer, 25*i+j);
         }
@@ -191,7 +191,7 @@ public class TestIndexWriter extends Luc
       // Now, build a starting index that has START_COUNT docs.  We
       // will then try to addIndexesNoOptimize into a copy of this:
       RAMDirectory startDir = new RAMDirectory();
-      IndexWriter writer = new IndexWriter(startDir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter writer = new IndexWriter(startDir, new IndexWriterConfig(TEST_VERSION_CURRENT));
       for(int j=0;j<START_COUNT;j++) {
         addDocWithIndex(writer, j);
       }
@@ -254,10 +254,10 @@ public class TestIndexWriter extends Luc
 
           // Make a new dir that will enforce disk usage:
           MockRAMDirectory dir = new MockRAMDirectory(startDir);
-          writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), false, IndexWriter.MaxFieldLength.UNLIMITED);
+          writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setOpenMode(OpenMode.APPEND));
           IOException err = null;
 
-          MergeScheduler ms = writer.getMergeScheduler();
+          MergeScheduler ms = writer.getConfig().getMergeScheduler();
           for(int x=0;x<2;x++) {
             if (ms instanceof ConcurrentMergeScheduler)
               // This test intentionally produces exceptions
@@ -466,9 +466,9 @@ public class TestIndexWriter extends Luc
             System.out.println("TEST: cycle: diskFree=" + diskFree);
           MockRAMDirectory dir = new MockRAMDirectory();
           dir.setMaxSizeInBytes(diskFree);
-          IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
+          IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
 
-          MergeScheduler ms = writer.getMergeScheduler();
+          MergeScheduler ms = writer.getConfig().getMergeScheduler();
           if (ms instanceof ConcurrentMergeScheduler)
             // This test intentionally produces exceptions
             // in the threads that CMS launches; we don't
@@ -544,7 +544,8 @@ public class TestIndexWriter extends Luc
     */
     public void testWickedLongTerm() throws IOException {
       RAMDirectory dir = new RAMDirectory();
-      IndexWriter writer  = new IndexWriter(dir, new StandardAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setAnalyzer(new StandardAnalyzer(TEST_VERSION_CURRENT)));
 
       char[] chars = new char[DocumentsWriter.CHAR_BLOCK_SIZE-1];
       Arrays.fill(chars, 'x');
@@ -590,7 +591,7 @@ public class TestIndexWriter extends Luc
       doc.add(new Field("content", bigTerm, Field.Store.NO, Field.Index.ANALYZED));
       StandardAnalyzer sa = new StandardAnalyzer(TEST_VERSION_CURRENT);
       sa.setMaxTokenLength(100000);
-      writer  = new IndexWriter(dir, sa, IndexWriter.MaxFieldLength.LIMITED);
+      writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setAnalyzer(sa));
       writer.addDocument(doc);
       writer.close();
       reader = IndexReader.open(dir, true);
@@ -608,12 +609,13 @@ public class TestIndexWriter extends Luc
       doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
 
       for(int numDocs=38;numDocs<500;numDocs += 38) {
-        IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+        IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+          TEST_VERSION_CURRENT).setOpenMode(OpenMode.CREATE)
+          .setMaxBufferedDocs(2));
         LogDocMergePolicy ldmp = new LogDocMergePolicy(writer);
         ldmp.setMinMergeDocs(1);
+        ldmp.setMergeFactor(5);
         writer.setMergePolicy(ldmp);
-        writer.setMergeFactor(5);
-        writer.setMaxBufferedDocs(2);
         for(int j=0;j<numDocs;j++)
           writer.addDocument(doc);
         writer.close();
@@ -622,9 +624,9 @@ public class TestIndexWriter extends Luc
         sis.read(dir);
         final int segCount = sis.size();
 
-        writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+        writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
+        ldmp.setMergeFactor(5);
         writer.setMergePolicy(ldmp);
-        writer.setMergeFactor(5);
         writer.optimize(3);
         writer.close();
 
@@ -645,18 +647,18 @@ public class TestIndexWriter extends Luc
       final Document doc = new Document();
       doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
 
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
       LogDocMergePolicy ldmp = new LogDocMergePolicy(writer);
       ldmp.setMinMergeDocs(1);
+      ldmp.setMergeFactor(4);
       writer.setMergePolicy(ldmp);
-      writer.setMergeFactor(4);
-      writer.setMaxBufferedDocs(2);
 
       for(int iter=0;iter<10;iter++) {
         for(int i=0;i<19;i++)
           writer.addDocument(doc);
 
-        ((ConcurrentMergeScheduler) writer.getMergeScheduler()).sync();
+        ((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).sync();
         writer.commit();
 
         SegmentInfos sis = new SegmentInfos();
@@ -668,7 +670,7 @@ public class TestIndexWriter extends Luc
         writer.commit();
 
         sis = new SegmentInfos();
-        ((ConcurrentMergeScheduler) writer.getMergeScheduler()).sync();
+        ((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).sync();
         sis.read(dir);
         final int optSegCount = sis.size();
 
@@ -687,7 +689,7 @@ public class TestIndexWriter extends Luc
     public void testOptimizeTempSpaceUsage() throws IOException {
     
       MockRAMDirectory dir = new MockRAMDirectory();
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
       for(int j=0;j<500;j++) {
         addDocWithIndex(writer, j);
       }
@@ -700,7 +702,7 @@ public class TestIndexWriter extends Luc
       }
 
       dir.resetMaxUsedSizeInBytes();
-      writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
+      writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setOpenMode(OpenMode.APPEND));
       writer.optimize();
       writer.close();
       long maxDiskUsage = dir.getMaxUsedSizeInBytes();
@@ -731,7 +733,7 @@ public class TestIndexWriter extends Luc
           Directory dir = FSDirectory.open(indexDir);
 
           // add one document & close writer
-          IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+          IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
           addDoc(writer);
           writer.close();
 
@@ -740,7 +742,7 @@ public class TestIndexWriter extends Luc
           assertEquals("should be one document", reader.numDocs(), 1);
 
           // now open index for create:
-          writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+          writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setOpenMode(OpenMode.CREATE));
           assertEquals("should be zero documents", writer.maxDoc(), 0);
           addDoc(writer);
           writer.close();
@@ -764,7 +766,7 @@ public class TestIndexWriter extends Luc
 
         IndexWriter writer = null;
 
-        writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+        writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
 
         // add 100 documents
         for (int i = 0; i < 100; i++) {
@@ -802,7 +804,7 @@ public class TestIndexWriter extends Luc
         reader.close();
 
         try {
-          writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+          writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setOpenMode(OpenMode.CREATE));
         } catch (Exception e) {
           fail("writer failed to open on a crashed index");
         }
@@ -824,7 +826,7 @@ public class TestIndexWriter extends Luc
 
         IndexWriter writer = null;
 
-        writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+        writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
 
         // add 100 documents
         for (int i = 0; i < 100; i++) {
@@ -867,7 +869,7 @@ public class TestIndexWriter extends Luc
 
         IndexWriter writer = null;
 
-        writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+        writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
         addDoc(writer);
 
         // close
@@ -889,7 +891,7 @@ public class TestIndexWriter extends Luc
 
         IndexWriter writer = null;
 
-        writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+        writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
 
         // add 100 documents
         for (int i = 0; i < 100; i++) {
@@ -928,7 +930,7 @@ public class TestIndexWriter extends Luc
      */
     public void testCommitOnClose() throws IOException {
         Directory dir = new RAMDirectory();      
-        IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+        IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
         for (int i = 0; i < 14; i++) {
           addDoc(writer);
         }
@@ -942,7 +944,7 @@ public class TestIndexWriter extends Luc
 
         IndexReader reader = IndexReader.open(dir, true);
 
-        writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+        writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
         for(int i=0;i<3;i++) {
           for(int j=0;j<11;j++) {
             addDoc(writer);
@@ -974,8 +976,7 @@ public class TestIndexWriter extends Luc
      */
     public void testCommitOnCloseAbort() throws IOException {
       MockRAMDirectory dir = new MockRAMDirectory();      
-      IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(10));
       for (int i = 0; i < 14; i++) {
         addDoc(writer);
       }
@@ -987,8 +988,8 @@ public class TestIndexWriter extends Luc
       assertEquals("first number of hits", 14, hits.length);
       searcher.close();
 
-      writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
+      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT)
+        .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10));
       for(int j=0;j<17;j++) {
         addDoc(writer);
       }
@@ -1012,8 +1013,8 @@ public class TestIndexWriter extends Luc
           
       // Now make sure we can re-open the index, add docs,
       // and all is good:
-      writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
+      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT)
+        .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10));
 
       // On abort, writer in fact may write to the same
       // segments_N file:
@@ -1047,7 +1048,7 @@ public class TestIndexWriter extends Luc
      */
     public void testCommitOnCloseDiskUsage() throws IOException {
       MockRAMDirectory dir = new MockRAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
       for(int j=0;j<30;j++) {
         addDocWithIndex(writer, j);
       }
@@ -1055,9 +1056,9 @@ public class TestIndexWriter extends Luc
       dir.resetMaxUsedSizeInBytes();
 
       long startDiskUsage = dir.getMaxUsedSizeInBytes();
-      writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
-      writer.setMergeScheduler(new SerialMergeScheduler());
+      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT)
+        .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10).setMergeScheduler(
+            new SerialMergeScheduler()));
       for(int j=0;j<1470;j++) {
         addDocWithIndex(writer, j);
       }
@@ -1090,14 +1091,13 @@ public class TestIndexWriter extends Luc
      */
     public void testCommitOnCloseOptimize() throws IOException {
       RAMDirectory dir = new RAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
+      IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(10));
       for(int j=0;j<17;j++) {
         addDocWithIndex(writer, j);
       }
       writer.close();
 
-      writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
+      writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setOpenMode(OpenMode.APPEND));
       writer.optimize();
 
       // Open a reader before closing (commiting) the writer:
@@ -1119,7 +1119,7 @@ public class TestIndexWriter extends Luc
       assertFalse("Reader incorrectly sees that the index is optimized", reader.isOptimized());
       reader.close();
 
-      writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
+      writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setOpenMode(OpenMode.APPEND));
       writer.optimize();
       writer.close();
       assertNoUnreferencedFiles(dir, "aborted writer after optimize");
@@ -1134,7 +1134,7 @@ public class TestIndexWriter extends Luc
 
     public void testIndexNoDocuments() throws IOException {
       RAMDirectory dir = new RAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
       writer.commit();
       writer.close();
 
@@ -1143,7 +1143,7 @@ public class TestIndexWriter extends Luc
       assertEquals(0, reader.numDocs());
       reader.close();
 
-      writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
+      writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setOpenMode(OpenMode.APPEND));
       writer.commit();
       writer.close();
 
@@ -1155,8 +1155,7 @@ public class TestIndexWriter extends Luc
 
     public void testManyFields() throws IOException {
       RAMDirectory dir = new RAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
+      IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(10));
       for(int j=0;j<100;j++) {
         Document doc = new Document();
         doc.add(new Field("a"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED));
@@ -1186,8 +1185,7 @@ public class TestIndexWriter extends Luc
 
     public void testSmallRAMBuffer() throws IOException {
       RAMDirectory dir = new RAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setRAMBufferSizeMB(0.000001);
+      IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setRAMBufferSizeMB(0.000001));
       int lastNumFile = dir.listAll().length;
       for(int j=0;j<9;j++) {
         Document doc = new Document();
@@ -1203,13 +1201,19 @@ public class TestIndexWriter extends Luc
       dir.close();
     }
 
-    // Make sure it's OK to change RAM buffer size and
-    // maxBufferedDocs in a write session
+    /**
+     * Make sure it's OK to change RAM buffer size and // maxBufferedDocs in a
+     * write session
+     * 
+     * @deprecated after all the setters on IW go away (4.0), this test can be
+     *             removed because changing ram buffer settings during a write
+     *             session won't be possible.
+     */
     public void testChangingRAMBuffer() throws IOException {
       RAMDirectory dir = new RAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
-      writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMaxBufferedDocs(10).setRAMBufferSizeMB(
+        IndexWriterConfig.DISABLE_AUTO_FLUSH));
 
       int lastFlushCount = -1;
       for(int j=1;j<52;j++) {
@@ -1227,30 +1231,30 @@ public class TestIndexWriter extends Luc
           assertTrue(flushCount > lastFlushCount);
           lastFlushCount = flushCount;
           writer.setRAMBufferSizeMB(0.000001);
-          writer.setMaxBufferedDocs(IndexWriter.DISABLE_AUTO_FLUSH);
+          writer.setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH);
         } else if (j < 20) {
           assertTrue(flushCount > lastFlushCount);
           lastFlushCount = flushCount;
         } else if (20 == j) {
           writer.setRAMBufferSizeMB(16);
-          writer.setMaxBufferedDocs(IndexWriter.DISABLE_AUTO_FLUSH);
+          writer.setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH);
           lastFlushCount = flushCount;
         } else if (j < 30) {
           assertEquals(flushCount, lastFlushCount);
         } else if (30 == j) {
           writer.setRAMBufferSizeMB(0.000001);
-          writer.setMaxBufferedDocs(IndexWriter.DISABLE_AUTO_FLUSH);
+          writer.setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH);
         } else if (j < 40) {
           assertTrue(flushCount> lastFlushCount);
           lastFlushCount = flushCount;
         } else if (40 == j) {
           writer.setMaxBufferedDocs(10);
-          writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
+          writer.setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH);
           lastFlushCount = flushCount;
         } else if (j < 50) {
           assertEquals(flushCount, lastFlushCount);
           writer.setMaxBufferedDocs(10);
-          writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
+          writer.setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH);
         } else if (50 == j) {
           assertTrue(flushCount > lastFlushCount);
         }
@@ -1259,12 +1263,15 @@ public class TestIndexWriter extends Luc
       dir.close();
     }
 
+    /**
+     * @deprecated after setters on IW go away, this test can be deleted because
+     *             changing those settings on IW won't be possible.
+     */
     public void testChangingRAMBuffer2() throws IOException {
       RAMDirectory dir = new RAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
-      writer.setMaxBufferedDeleteTerms(10);
-      writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMaxBufferedDocs(10).setMaxBufferedDeleteTerms(
+        10).setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH));
 
       for(int j=1;j<52;j++) {
         Document doc = new Document();
@@ -1292,25 +1299,25 @@ public class TestIndexWriter extends Luc
           lastFlushCount = flushCount;
         } else if (20 == j) {
           writer.setRAMBufferSizeMB(16);
-          writer.setMaxBufferedDeleteTerms(IndexWriter.DISABLE_AUTO_FLUSH);
+          writer.setMaxBufferedDeleteTerms(IndexWriterConfig.DISABLE_AUTO_FLUSH);
           lastFlushCount = flushCount;
         } else if (j < 30) {
           assertEquals(flushCount, lastFlushCount);
         } else if (30 == j) {
           writer.setRAMBufferSizeMB(0.000001);
-          writer.setMaxBufferedDeleteTerms(IndexWriter.DISABLE_AUTO_FLUSH);
+          writer.setMaxBufferedDeleteTerms(IndexWriterConfig.DISABLE_AUTO_FLUSH);
           writer.setMaxBufferedDeleteTerms(1);
         } else if (j < 40) {
           assertTrue(flushCount> lastFlushCount);
           lastFlushCount = flushCount;
         } else if (40 == j) {
           writer.setMaxBufferedDeleteTerms(10);
-          writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
+          writer.setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH);
           lastFlushCount = flushCount;
         } else if (j < 50) {
           assertEquals(flushCount, lastFlushCount);
           writer.setMaxBufferedDeleteTerms(10);
-          writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
+          writer.setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH);
         } else if (50 == j) {
           assertTrue(flushCount > lastFlushCount);
         }
@@ -1321,8 +1328,7 @@ public class TestIndexWriter extends Luc
 
     public void testDiverseDocs() throws IOException {
       RAMDirectory dir = new RAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setRAMBufferSizeMB(0.5);
+      IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setRAMBufferSizeMB(0.5));
       Random rand = newRandom();
       for(int i=0;i<3;i++) {
         // First, docs where every term is unique (heavy on
@@ -1370,8 +1376,7 @@ public class TestIndexWriter extends Luc
 
     public void testEnablingNorms() throws IOException {
       RAMDirectory dir = new RAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
+      IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(10));
       // Enable norms for only 1 doc, pre flush
       for(int j=0;j<10;j++) {
         Document doc = new Document();
@@ -1391,8 +1396,8 @@ public class TestIndexWriter extends Luc
       assertEquals(10, hits.length);
       searcher.close();
 
-      writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
+      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT)
+        .setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(10));
       // Enable norms for only 1 doc, post flush
       for(int j=0;j<27;j++) {
         Document doc = new Document();
@@ -1417,8 +1422,8 @@ public class TestIndexWriter extends Luc
 
     public void testHighFreqTerm() throws IOException {
       RAMDirectory dir = new RAMDirectory();      
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, new IndexWriter.MaxFieldLength(100000000));
-      writer.setRAMBufferSizeMB(0.01);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+          TEST_VERSION_CURRENT).setMaxFieldLength(100000000).setRAMBufferSizeMB(0.01));
       // Massive doc that has 128 K a's
       StringBuilder b = new StringBuilder(1024*1024);
       for(int i=0;i<4096;i++) {
@@ -1464,7 +1469,8 @@ public class TestIndexWriter extends Luc
       }
       
       Directory dir = new MyRAMDirectory();
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT));
       for (int i = 0; i < 100; i++) {
         addDoc(writer);
       }
@@ -1475,7 +1481,8 @@ public class TestIndexWriter extends Luc
       assertEquals("did not get right number of hits", 100, hits.length);
       writer.close();
 
-      writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT)
+        .setOpenMode(OpenMode.CREATE));
       writer.close();
 
       dir.close();
@@ -1483,8 +1490,8 @@ public class TestIndexWriter extends Luc
 
     public void testFlushWithNoMerging() throws IOException {
       Directory dir = new RAMDirectory();
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(2);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
       Document doc = new Document();
       doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
       for(int i=0;i<19;i++)
@@ -1502,7 +1509,7 @@ public class TestIndexWriter extends Luc
     // empty doc (no norms) and flush
     public void testEmptyDocAfterFlushingRealDoc() throws IOException {
       Directory dir = new RAMDirectory();
-      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
       Document doc = new Document();
       doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
       writer.addDocument(doc);
@@ -1521,12 +1528,12 @@ public class TestIndexWriter extends Luc
 
       Directory dir = new MockRAMDirectory();
       for(int pass=0;pass<2;pass++) {
-        IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-        writer.setMergeScheduler(new ConcurrentMergeScheduler());
+        IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+          TEST_VERSION_CURRENT).setOpenMode(OpenMode.CREATE)
+          .setMaxBufferedDocs(2));
+        ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(101);
         Document doc = new Document();
         doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
-        writer.setMaxBufferedDocs(2);
-        writer.setMergeFactor(101);
         for(int i=0;i<200;i++)
           writer.addDocument(doc);
         writer.optimize(false);
@@ -1575,11 +1582,10 @@ public class TestIndexWriter extends Luc
    */
   public void testBadSegment() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter ir = new IndexWriter(dir, new StandardAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter ir = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     
     Document document = new Document();
-    document.add(new Field("tvtest", "", Field.Store.NO, Field.Index.ANALYZED,
-        Field.TermVector.YES));
+    document.add(new Field("tvtest", "", Store.NO, Index.ANALYZED, TermVector.YES));
     ir.addDocument(document);
     ir.close();
     dir.close();
@@ -1588,7 +1594,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1008
   public void testNoTermVectorAfterTermVector() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document document = new Document();
     document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
         Field.TermVector.YES));
@@ -1614,7 +1620,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1010
   public void testNoTermVectorAfterTermVectorMerge() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document document = new Document();
     document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
         Field.TermVector.YES));
@@ -1646,12 +1652,11 @@ public class TestIndexWriter extends Luc
     int pri = Thread.currentThread().getPriority();
     try {
       MockRAMDirectory dir = new MockRAMDirectory();
-      IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
+      ((LogMergePolicy) iw.getMergePolicy()).setMergeFactor(2);
       Document document = new Document();
       document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
                              Field.TermVector.YES));
-      iw.setMaxBufferedDocs(2);
-      iw.setMergeFactor(2);
       Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
       for(int i=0;i<4;i++)
         iw.addDocument(document);
@@ -1686,11 +1691,12 @@ public class TestIndexWriter extends Luc
   // LUCENE-1013
   public void testSetMaxMergeDocs() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
-    iw.setMergeScheduler(new MyMergeScheduler());
-    iw.setMaxMergeDocs(20);
-    iw.setMaxBufferedDocs(2);
-    iw.setMergeFactor(2);
+    IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMergeScheduler(new MyMergeScheduler())
+        .setMaxBufferedDocs(2));
+    LogMergePolicy lmp = (LogMergePolicy) iw.getMergePolicy();
+    lmp.setMaxMergeDocs(20);
+    lmp.setMergeFactor(2);
     Document document = new Document();
     document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
                            Field.TermVector.YES));
@@ -1702,7 +1708,8 @@ public class TestIndexWriter extends Luc
   // LUCENE-1072
   public void testExceptionFromTokenStream() throws IOException {
     RAMDirectory dir = new MockRAMDirectory();
-    IndexWriter writer = new IndexWriter(dir, new Analyzer() {
+    IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT);
+    conf.setAnalyzer(new Analyzer() {
 
       @Override
       public TokenStream tokenStream(String fieldName, Reader reader) {
@@ -1719,7 +1726,8 @@ public class TestIndexWriter extends Luc
         };
       }
 
-    }, true, IndexWriter.MaxFieldLength.LIMITED);
+    });
+    IndexWriter writer = new IndexWriter(dir, conf);
 
     Document doc = new Document();
     String contents = "aa bb cc dd ee ff gg hh ii jj kk";
@@ -1804,8 +1812,7 @@ public class TestIndexWriter extends Luc
     failure.setDoFail();
     dir.failOn(failure);
 
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMaxBufferedDocs(2);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
     Document doc = new Document();
     String contents = "aa bb cc dd ee ff gg hh ii jj kk";
     doc.add(new Field("content", contents, Field.Store.NO,
@@ -1860,7 +1867,7 @@ public class TestIndexWriter extends Luc
 
     for(int i=0;i<2;i++) {
       MockRAMDirectory dir = new MockRAMDirectory();
-      IndexWriter writer = new IndexWriter(dir, analyzer, IndexWriter.MaxFieldLength.LIMITED);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setAnalyzer(analyzer));
       //writer.setInfoStream(System.out);
       Document doc = new Document();
       doc.add(new Field("contents", "here are some contents", Field.Store.YES,
@@ -1903,8 +1910,8 @@ public class TestIndexWriter extends Luc
 
       assertEquals(1, numDel);
 
-      writer = new IndexWriter(dir, analyzer, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
+      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT)
+          .setAnalyzer(analyzer).setMaxBufferedDocs(10));
       doc = new Document();
       doc.add(new Field("contents", "here are some contents", Field.Store.YES,
                         Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
@@ -1948,7 +1955,7 @@ public class TestIndexWriter extends Luc
       MockRAMDirectory dir = new MockRAMDirectory();
 
       {
-        final IndexWriter writer = new IndexWriter(dir, analyzer, IndexWriter.MaxFieldLength.LIMITED);
+        final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setAnalyzer(analyzer));
 
         final int finalI = i;
 
@@ -2017,8 +2024,8 @@ public class TestIndexWriter extends Luc
 
       assertEquals(NUM_THREAD*NUM_ITER, numDel);
 
-      IndexWriter writer = new IndexWriter(dir, analyzer, IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(10);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+          TEST_VERSION_CURRENT).setAnalyzer(analyzer).setMaxBufferedDocs(10));
       Document doc = new Document();
       doc.add(new Field("contents", "here are some contents", Field.Store.YES,
                         Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
@@ -2051,10 +2058,11 @@ public class TestIndexWriter extends Luc
     MockRAMDirectory dir = new MockRAMDirectory();
     int delID = 0;
     for(int i=0;i<20;i++) {
-      IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(2);
-      writer.setMergeFactor(2);
-      writer.setUseCompoundFile(false);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
+      LogMergePolicy lmp = (LogMergePolicy) writer.getMergePolicy();
+      lmp.setMergeFactor(2);
+      lmp.setUseCompoundFile(false);
+      lmp.setUseCompoundDocStore(false);
       Document doc = new Document();
       String contents = "aa bb cc dd ee ff gg hh ii jj kk";
 
@@ -2087,8 +2095,10 @@ public class TestIndexWriter extends Luc
       reader.close();
 
       if (0 == i % 4) {
-        writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-        writer.setUseCompoundFile(false);
+        writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
+        LogMergePolicy lmp2 = (LogMergePolicy) writer.getMergePolicy();
+        lmp2.setUseCompoundFile(false);
+        lmp2.setUseCompoundDocStore(false);
         writer.optimize();
         writer.close();
       }
@@ -2104,21 +2114,18 @@ public class TestIndexWriter extends Luc
 
     for(int pass=0;pass<2;pass++) {
 
-      IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
-
+      IndexWriterConfig conf = new IndexWriterConfig(
+          TEST_VERSION_CURRENT).setOpenMode(OpenMode.CREATE)
+          .setMaxBufferedDocs(2);
+      if (pass == 2) {
+        conf.setMergeScheduler(new SerialMergeScheduler());
+      }
+      IndexWriter writer = new IndexWriter(directory, conf);
+      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(100);
+      
       //System.out.println("TEST: pass=" + pass + " cms=" + (pass >= 2));
       for(int iter=0;iter<10;iter++) {
         //System.out.println("TEST: iter=" + iter);
-        MergeScheduler ms;
-        if (pass == 1)
-          ms = new ConcurrentMergeScheduler();
-        else
-          ms = new SerialMergeScheduler();
-        
-        writer.setMergeScheduler(ms);
-        writer.setMaxBufferedDocs(2);
-        writer.setMergeFactor(100);
-
         for(int j=0;j<199;j++) {
           idField.setValue(Integer.toString(iter*201+j));
           writer.addDocument(doc);
@@ -2132,7 +2139,7 @@ public class TestIndexWriter extends Luc
 
         // Force a bunch of merge threads to kick off so we
         // stress out aborting them on close:
-        writer.setMergeFactor(2);
+        ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
 
         final IndexWriter finalWriter = writer;
         final ArrayList<Throwable> failure = new ArrayList<Throwable>();
@@ -2176,7 +2183,7 @@ public class TestIndexWriter extends Luc
         reader.close();
 
         // Reopen
-        writer = new IndexWriter(directory, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), false, IndexWriter.MaxFieldLength.UNLIMITED);
+        writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT).setOpenMode(OpenMode.APPEND));
       }
       writer.close();
     }
@@ -2256,15 +2263,11 @@ public class TestIndexWriter extends Luc
 
     for(int iter=0;iter<7;iter++) {
       MockRAMDirectory dir = new MockRAMDirectory();
-      IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-      ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
-
+      IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(10);
       // We expect AlreadyClosedException
-      cms.setSuppressExceptions();
-
-      writer.setMergeScheduler(cms);
-      writer.setMaxBufferedDocs(10);
-      writer.setMergeFactor(4);
+      ((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
+      IndexWriter writer = new IndexWriter(dir, conf);
+      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(4);
 
       IndexerThread[] threads = new IndexerThread[NUM_THREADS];
 
@@ -2315,9 +2318,8 @@ public class TestIndexWriter extends Luc
   // OK:
   public void testImmediateDiskFull() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
     dir.setMaxSizeInBytes(dir.getRecomputedActualSizeInBytes());
-    writer.setMaxBufferedDocs(2);
     final Document doc = new Document();
     doc.add(new Field("field", "aaa bbb ccc ddd eee fff ggg hhh iii jjj", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
     try {
@@ -2353,13 +2355,11 @@ public class TestIndexWriter extends Luc
 
     for(int iter=0;iter<10;iter++) {
       MockRAMDirectory dir = new MockRAMDirectory();
-      IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
-      ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
+      IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2);
       // We expect disk full exceptions in the merge threads
-      cms.setSuppressExceptions();
-      writer.setMergeScheduler(cms);
-      writer.setMaxBufferedDocs(2);
-      writer.setMergeFactor(4);
+      ((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
+      IndexWriter writer = new IndexWriter(dir, conf);
+      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(4);
       dir.setMaxSizeInBytes(4*1024+20*iter);
 
       IndexerThread[] threads = new IndexerThread[NUM_THREADS];
@@ -2414,8 +2414,7 @@ public class TestIndexWriter extends Luc
   public void _testSingleThreadFailure(MockRAMDirectory.Failure failure) throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
-    writer.setMaxBufferedDocs(2);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
     final Document doc = new Document();
     doc.add(new Field("field", "aaa bbb ccc ddd eee fff ggg hhh iii jjj", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
 
@@ -2444,13 +2443,11 @@ public class TestIndexWriter extends Luc
 
     for(int iter=0;iter<2;iter++) {
       MockRAMDirectory dir = new MockRAMDirectory();
-      IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-      ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
+      IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2);
       // We expect disk full exceptions in the merge threads
-      cms.setSuppressExceptions();
-      writer.setMergeScheduler(cms);
-      writer.setMaxBufferedDocs(2);
-      writer.setMergeFactor(4);
+      ((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
+      IndexWriter writer = new IndexWriter(dir, conf);
+      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(4);
 
       IndexerThread[] threads = new IndexerThread[NUM_THREADS];
 
@@ -2604,7 +2601,7 @@ public class TestIndexWriter extends Luc
   public void testUnlimitedMaxFieldLength() throws IOException {
     Directory dir = new MockRAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
 
     Document doc = new Document();
     StringBuilder b = new StringBuilder();
@@ -2628,7 +2625,7 @@ public class TestIndexWriter extends Luc
 
     IndexWriter writer = null;
 
-    writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
 
     // add 100 documents
     for (int i = 0; i < 100; i++) {
@@ -2664,9 +2661,8 @@ public class TestIndexWriter extends Luc
   public void testForceCommit() throws IOException {
     Directory dir = new MockRAMDirectory();
 
-    IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMaxBufferedDocs(2);
-    writer.setMergeFactor(5);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
+    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
 
     for (int i = 0; i < 23; i++)
       addDoc(writer);
@@ -2718,13 +2714,9 @@ public class TestIndexWriter extends Luc
     FailOnlyInSync failure = new FailOnlyInSync();
     dir.failOn(failure);
 
-    IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
     failure.setDoFail();
-
-    ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
-    writer.setMergeScheduler(cms);
-    writer.setMaxBufferedDocs(2);
-    writer.setMergeFactor(5);
+    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
 
     for (int i = 0; i < 23; i++) {
       addDoc(writer);
@@ -2737,7 +2729,7 @@ public class TestIndexWriter extends Luc
       }
     }
 
-    cms.sync();
+    ((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).sync();
     assertTrue(failure.didFail);
     failure.clearDoFail();
     writer.close();
@@ -2753,11 +2745,10 @@ public class TestIndexWriter extends Luc
 
     Directory dir = new MockRAMDirectory();
     for(int iter=0;iter<2;iter++) {
-      IndexWriter writer = new IndexWriter(dir,
-                                           new StandardAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
-      writer.setMaxBufferedDocs(2);
-      writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
-      writer.setMergeScheduler(new SerialMergeScheduler());
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+          TEST_VERSION_CURRENT).setMaxBufferedDocs(2).setRAMBufferSizeMB(
+          IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergeScheduler(
+          new SerialMergeScheduler()));
       writer.setMergePolicy(new LogDocMergePolicy(writer));
 
       Document document = new Document();
@@ -2786,11 +2777,10 @@ public class TestIndexWriter extends Luc
       }
       reader.close();
 
-      writer = new IndexWriter(dir,
-                               new StandardAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
-      writer.setMaxBufferedDocs(2);
-      writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
-      writer.setMergeScheduler(new SerialMergeScheduler());
+      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT)
+          .setMaxBufferedDocs(2).setRAMBufferSizeMB(
+              IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergeScheduler(
+              new SerialMergeScheduler()));
       writer.setMergePolicy(new LogDocMergePolicy(writer));
 
       Directory[] indexDirs = {new MockRAMDirectory(dir)};
@@ -2805,11 +2795,10 @@ public class TestIndexWriter extends Luc
   public void testTermVectorCorruption2() throws IOException {
     Directory dir = new MockRAMDirectory();
     for(int iter=0;iter<2;iter++) {
-      IndexWriter writer = new IndexWriter(dir,
-                                           new StandardAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
-      writer.setMaxBufferedDocs(2);
-      writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
-      writer.setMergeScheduler(new SerialMergeScheduler());
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+          TEST_VERSION_CURRENT).setMaxBufferedDocs(2).setRAMBufferSizeMB(
+          IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergeScheduler(
+          new SerialMergeScheduler()));
       writer.setMergePolicy(new LogDocMergePolicy(writer));
 
       Document document = new Document();
@@ -2842,12 +2831,10 @@ public class TestIndexWriter extends Luc
   // LUCENE-1168
   public void testTermVectorCorruption3() throws IOException {
     Directory dir = new MockRAMDirectory();
-    IndexWriter writer = new IndexWriter(dir,
-                                         new StandardAnalyzer(TEST_VERSION_CURRENT),
-                                         IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMaxBufferedDocs(2);
-    writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
-    writer.setMergeScheduler(new SerialMergeScheduler());
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMaxBufferedDocs(2).setRAMBufferSizeMB(
+        IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergeScheduler(
+        new SerialMergeScheduler()));
     writer.setMergePolicy(new LogDocMergePolicy(writer));
 
     Document document = new Document();
@@ -2864,12 +2851,10 @@ public class TestIndexWriter extends Luc
       writer.addDocument(document);
     writer.close();
 
-    writer = new IndexWriter(dir,
-                             new StandardAnalyzer(TEST_VERSION_CURRENT),
-                             IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMaxBufferedDocs(2);
-    writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
-    writer.setMergeScheduler(new SerialMergeScheduler());
+    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT)
+        .setMaxBufferedDocs(2).setRAMBufferSizeMB(
+            IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergeScheduler(
+            new SerialMergeScheduler()));
     writer.setMergePolicy(new LogDocMergePolicy(writer));
     for(int i=0;i<6;i++)
       writer.addDocument(document);
@@ -2890,7 +2875,8 @@ public class TestIndexWriter extends Luc
   public void testUserSpecifiedMaxFieldLength() throws IOException {
     Directory dir = new MockRAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), new IndexWriter.MaxFieldLength(100000));
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMaxFieldLength(100000));
 
     Document doc = new Document();
     StringBuilder b = new StringBuilder();
@@ -2912,11 +2898,9 @@ public class TestIndexWriter extends Luc
   // are required
   public void testExpungeDeletes() throws IOException {
     Directory dir = new MockRAMDirectory();
-    IndexWriter writer = new IndexWriter(dir,
-                                         new StandardAnalyzer(TEST_VERSION_CURRENT),
-                                         IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMaxBufferedDocs(2);
-    writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMaxBufferedDocs(2).setRAMBufferSizeMB(
+        IndexWriterConfig.DISABLE_AUTO_FLUSH));
 
     Document document = new Document();
 
@@ -2940,9 +2924,7 @@ public class TestIndexWriter extends Luc
     assertEquals(8, ir.numDocs());
     ir.close();
 
-    writer = new IndexWriter(dir,
-                             new StandardAnalyzer(TEST_VERSION_CURRENT),
-                             IndexWriter.MaxFieldLength.LIMITED);
+    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     assertEquals(8, writer.numDocs());
     assertEquals(10, writer.maxDoc());
     writer.expungeDeletes();
@@ -2958,12 +2940,10 @@ public class TestIndexWriter extends Luc
   // LUCENE-325: test expungeDeletes, when many adjacent merges are required
   public void testExpungeDeletes2() throws IOException {
     Directory dir = new MockRAMDirectory();
-    IndexWriter writer = new IndexWriter(dir,
-                                         new StandardAnalyzer(TEST_VERSION_CURRENT),
-                                         IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMaxBufferedDocs(2);
-    writer.setMergeFactor(50);
-    writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMaxBufferedDocs(2).setRAMBufferSizeMB(
+        IndexWriterConfig.DISABLE_AUTO_FLUSH));
+    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(50);
 
     Document document = new Document();
 
@@ -2987,10 +2967,8 @@ public class TestIndexWriter extends Luc
     assertEquals(49, ir.numDocs());
     ir.close();
 
-    writer = new IndexWriter(dir,
-                             new StandardAnalyzer(TEST_VERSION_CURRENT),
-                             IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMergeFactor(3);
+    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
+    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(3);
     assertEquals(49, writer.numDocs());
     writer.expungeDeletes();
     writer.close();
@@ -3005,12 +2983,10 @@ public class TestIndexWriter extends Luc
   // many adjacent merges are required
   public void testExpungeDeletes3() throws IOException {
     Directory dir = new MockRAMDirectory();
-    IndexWriter writer = new IndexWriter(dir,
-                                         new StandardAnalyzer(TEST_VERSION_CURRENT),
-                                         IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMaxBufferedDocs(2);
-    writer.setMergeFactor(50);
-    writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setMaxBufferedDocs(2).setRAMBufferSizeMB(
+        IndexWriterConfig.DISABLE_AUTO_FLUSH));
+    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(50);
 
     Document document = new Document();
 
@@ -3034,11 +3010,9 @@ public class TestIndexWriter extends Luc
     assertEquals(49, ir.numDocs());
     ir.close();
 
-    writer = new IndexWriter(dir,
-                             new StandardAnalyzer(TEST_VERSION_CURRENT),
-                             IndexWriter.MaxFieldLength.LIMITED);
+    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     // Force many merges to happen
-    writer.setMergeFactor(3);
+    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(3);
     writer.expungeDeletes(false);
     writer.close();
     ir = IndexReader.open(dir, true);
@@ -3051,7 +3025,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1179
   public void testEmptyFieldName() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     doc.add(new Field("", "a b c", Field.Store.NO, Field.Index.ANALYZED));
     writer.addDocument(doc);
@@ -3059,10 +3033,10 @@ public class TestIndexWriter extends Luc
   }
 
   // LUCENE-1198
-  public class MockIndexWriter extends IndexWriter {
+  private static final class MockIndexWriter extends IndexWriter {
 
-    public MockIndexWriter(Directory dir, Analyzer a, boolean create, MaxFieldLength mfl) throws IOException {
-      super(dir, a, create, mfl);
+    public MockIndexWriter(Directory dir, IndexWriterConfig conf) throws IOException {
+      super(dir, conf);
     }
 
     boolean doFail;
@@ -3074,10 +3048,11 @@ public class TestIndexWriter extends Luc
       return true;
     }
   }
+  
 
   public void testExceptionDocumentsWriterInit() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    MockIndexWriter w = new MockIndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    MockIndexWriter w = new MockIndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     doc.add(new Field("field", "a field", Field.Store.YES,
                       Field.Index.ANALYZED));
@@ -3097,8 +3072,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1208
   public void testExceptionJustBeforeFlush() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    MockIndexWriter w = new MockIndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
-    w.setMaxBufferedDocs(2);
+    MockIndexWriter w = new MockIndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
     Document doc = new Document();
     doc.add(new Field("field", "a field", Field.Store.YES,
                       Field.Index.ANALYZED));
@@ -3125,10 +3099,10 @@ public class TestIndexWriter extends Luc
     dir.close();
   }    
 
-  public class MockIndexWriter2 extends IndexWriter {
+  private static final class MockIndexWriter2 extends IndexWriter {
 
-    public MockIndexWriter2(Directory dir, Analyzer a, boolean create, MaxFieldLength mfl) throws IOException {
-      super(dir, a, create, mfl);
+    public MockIndexWriter2(Directory dir, IndexWriterConfig conf) throws IOException {
+      super(dir, conf);
     }
 
     boolean doFail;
@@ -3143,15 +3117,14 @@ public class TestIndexWriter extends Luc
       return true;
     }
   }
+  
 
   // LUCENE-1210
   public void testExceptionOnMergeInit() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    MockIndexWriter2 w = new MockIndexWriter2(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
-    w.setMaxBufferedDocs(2);
-    w.setMergeFactor(2);
+    MockIndexWriter2 w = new MockIndexWriter2(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
+    ((LogMergePolicy) w.getMergePolicy()).setMergeFactor(2);
     w.doFail = true;
-    w.setMergeScheduler(new ConcurrentMergeScheduler());
     Document doc = new Document();
     doc.add(new Field("field", "a field", Field.Store.YES,
                       Field.Index.ANALYZED));
@@ -3162,16 +3135,16 @@ public class TestIndexWriter extends Luc
         break;
       }
 
-    ((ConcurrentMergeScheduler) w.getMergeScheduler()).sync();
+    ((ConcurrentMergeScheduler) w.getConfig().getMergeScheduler()).sync();
     assertTrue(w.failed);
     w.close();
     dir.close();
   }
 
-  public class MockIndexWriter3 extends IndexWriter {
+  private static final class MockIndexWriter3 extends IndexWriter {
 
-    public MockIndexWriter3(Directory dir, Analyzer a, boolean create, IndexWriter.MaxFieldLength mfl) throws IOException {
-      super(dir, a, create, mfl);
+    public MockIndexWriter3(Directory dir, IndexWriterConfig conf) throws IOException {
+      super(dir, conf);
     }
 
     boolean afterWasCalled;
@@ -3187,11 +3160,12 @@ public class TestIndexWriter extends Luc
       beforeWasCalled = true;
     }
   }
+  
 
   // LUCENE-1222
   public void testDoBeforeAfterFlush() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    MockIndexWriter3 w = new MockIndexWriter3(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+    MockIndexWriter3 w = new MockIndexWriter3(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     doc.add(new Field("field", "a field", Field.Store.YES,
                       Field.Index.ANALYZED));
@@ -3242,12 +3216,13 @@ public class TestIndexWriter extends Luc
       }
     }
   }
+  
 
   // LUCENE-1214
   public void testExceptionsDuringCommit() throws Throwable {
     MockRAMDirectory dir = new MockRAMDirectory();
     FailOnlyInCommit failure = new FailOnlyInCommit();
-    IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     doc.add(new Field("field", "a field", Field.Store.YES,
                       Field.Index.ANALYZED));
@@ -3295,7 +3270,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-510
   public void testInvalidUTF16() throws Throwable {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
 
     final int count = utf8Data.length/2;
@@ -3508,7 +3483,7 @@ public class TestIndexWriter extends Luc
     };
 
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     doc.add(new Field("field", tokens));
     w.addDocument(doc);
@@ -3540,9 +3515,8 @@ public class TestIndexWriter extends Luc
   public void testPrepareCommit() throws IOException {
     Directory dir = new MockRAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMaxBufferedDocs(2);
-    writer.setMergeFactor(5);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
+    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
 
     for (int i = 0; i < 23; i++)
       addDoc(writer);
@@ -3592,10 +3566,8 @@ public class TestIndexWriter extends Luc
     MockRAMDirectory dir = new MockRAMDirectory();
     dir.setPreventDoubleWrite(false);
 
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-
-    writer.setMaxBufferedDocs(2);
-    writer.setMergeFactor(5);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
+    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
 
     for (int i = 0; i < 23; i++)
       addDoc(writer);
@@ -3617,7 +3589,7 @@ public class TestIndexWriter extends Luc
     reader.close();
     reader2.close();
 
-    writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     for (int i = 0; i < 17; i++)
       addDoc(writer);
 
@@ -3645,7 +3617,7 @@ public class TestIndexWriter extends Luc
   public void testPrepareCommitNoChanges() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     writer.prepareCommit();
     writer.commit();
     writer.close();
@@ -3672,15 +3644,14 @@ public class TestIndexWriter extends Luc
     public RunAddIndexesThreads(int numCopy) throws Throwable {
       NUM_COPY = numCopy;
       dir = new MockRAMDirectory();
-      IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-      writer.setMaxBufferedDocs(2);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
       for (int i = 0; i < NUM_INIT_DOCS; i++)
         addDoc(writer);
       writer.close();
 
       dir2 = new MockRAMDirectory();
-      writer2 = new IndexWriter(dir2, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-      cms = (ConcurrentMergeScheduler) writer2.getMergeScheduler();
+      writer2 = new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT));
+      cms = (ConcurrentMergeScheduler) writer2.getConfig().getMergeScheduler();
 
       readers = new IndexReader[NUM_COPY];
       for(int i=0;i<NUM_COPY;i++)
@@ -3925,10 +3896,10 @@ public class TestIndexWriter extends Luc
   }
 
   // LUCENE-1347
-  public class MockIndexWriter4 extends IndexWriter {
+  private static final class MockIndexWriter4 extends IndexWriter {
 
-    public MockIndexWriter4(Directory dir, Analyzer a, boolean create, MaxFieldLength mfl) throws IOException {
-      super(dir, a, create, mfl);
+    public MockIndexWriter4(Directory dir, IndexWriterConfig conf) throws IOException {
+      super(dir, conf);
     }
 
     boolean doFail;
@@ -3940,11 +3911,12 @@ public class TestIndexWriter extends Luc
       return true;
     }
   }
+  
 
   // LUCENE-1347
   public void testRollbackExceptionHang() throws Throwable {
     MockRAMDirectory dir = new MockRAMDirectory();
-    MockIndexWriter4 w = new MockIndexWriter4(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+    MockIndexWriter4 w = new MockIndexWriter4(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
 
     addDoc(w);
     w.doFail = true;
@@ -3963,7 +3935,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1219
   public void testBinaryFieldOffsetLength() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     byte[] b = new byte[50];
     for(int i=0;i<50;i++)
       b[i] = (byte) (i+77);
@@ -3993,8 +3965,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1382
   public void testCommitUserData() throws IOException {
     Directory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-    w.setMaxBufferedDocs(2);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
     for(int j=0;j<17;j++)
       addDoc(w);
     w.close();
@@ -4006,8 +3977,7 @@ public class TestIndexWriter extends Luc
     assertEquals(0, r.getCommitUserData().size());
     r.close();
       
-    w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
-    w.setMaxBufferedDocs(2);
+    w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
     for(int j=0;j<17;j++)
       addDoc(w);
     Map<String,String> data = new HashMap<String,String>();
@@ -4021,7 +3991,7 @@ public class TestIndexWriter extends Luc
     assertEquals("test1", r.getCommitUserData().get("label"));
     r.close();
 
-    w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     w.optimize();
     w.close();
 
@@ -4032,17 +4002,17 @@ public class TestIndexWriter extends Luc
 
   public void testOptimizeExceptions() throws IOException {
     RAMDirectory startDir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(startDir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);    
-    w.setMaxBufferedDocs(2);
-    w.setMergeFactor(100);
+    IndexWriter w = new IndexWriter(startDir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
+    ((LogMergePolicy) w.getMergePolicy()).setMergeFactor(100);
     for(int i=0;i<27;i++)
       addDoc(w);
     w.close();
 
     for(int i=0;i<200;i++) {
       MockRAMDirectory dir = new MockRAMDirectory(startDir);
-      w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
-      ((ConcurrentMergeScheduler) w.getMergeScheduler()).setSuppressExceptions();
+      IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT);
+      ((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
+      w = new IndexWriter(dir, conf);
       dir.setRandomIOExceptionRate(0.5, 100);
       try {
         w.optimize();
@@ -4060,7 +4030,7 @@ public class TestIndexWriter extends Luc
 
     final List<Throwable> thrown = new ArrayList<Throwable>();
 
-    final IndexWriter writer = new IndexWriter(new MockRAMDirectory(), new StandardAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED) {
+    final IndexWriter writer = new IndexWriter(new MockRAMDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT)) {
         @Override
         public void message(final String message) {
           if (message.startsWith("now flush at close") && 0 == thrown.size()) {
@@ -4085,7 +4055,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1442
   public void testDoubleOffsetCounting() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     Field f = new Field("field", "abcd", Field.Store.NO, Field.Index.NOT_ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
     doc.add(f);
@@ -4120,7 +4090,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1442
   public void testDoubleOffsetCounting2() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new SimpleAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     Field f = new Field("field", "abcd", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
     doc.add(f);
@@ -4142,7 +4112,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1448
   public void testEndOffsetPositionCharAnalyzer() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     Field f = new Field("field", "abcd   ", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
     doc.add(f);
@@ -4165,7 +4135,7 @@ public class TestIndexWriter extends Luc
   public void testEndOffsetPositionWithCachingTokenFilter() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
     Analyzer analyzer = new WhitespaceAnalyzer(TEST_VERSION_CURRENT);
-    IndexWriter w = new IndexWriter(dir, analyzer, IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setAnalyzer(analyzer));
     Document doc = new Document();
     TokenStream stream = new CachingTokenFilter(analyzer.tokenStream("field", new StringReader("abcd   ")));
     Field f = new Field("field", stream, Field.TermVector.WITH_POSITIONS_OFFSETS);
@@ -4189,7 +4159,7 @@ public class TestIndexWriter extends Luc
   public void testEndOffsetPositionWithTeeSinkTokenFilter() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
     Analyzer analyzer = new WhitespaceAnalyzer(TEST_VERSION_CURRENT);
-    IndexWriter w = new IndexWriter(dir, analyzer, IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setAnalyzer(analyzer));
     Document doc = new Document();
     TeeSinkTokenFilter tee = new TeeSinkTokenFilter(analyzer.tokenStream("field", new StringReader("abcd   ")));
     TokenStream sink = tee.newSinkTokenStream();
@@ -4214,7 +4184,9 @@ public class TestIndexWriter extends Luc
   // LUCENE-1448
   public void testEndOffsetPositionStopFilter() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new StopAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT)
+        .setAnalyzer(new StopAnalyzer(TEST_VERSION_CURRENT)));
     Document doc = new Document();
     Field f = new Field("field", "abcd the", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
     doc.add(f);
@@ -4236,7 +4208,9 @@ public class TestIndexWriter extends Luc
   // LUCENE-1448
   public void testEndOffsetPositionStandard() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setAnalyzer(new StandardAnalyzer(
+        TEST_VERSION_CURRENT)));
     Document doc = new Document();
     Field f = new Field("field", "abcd the  ", Field.Store.NO,
         Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
@@ -4266,7 +4240,9 @@ public class TestIndexWriter extends Luc
   // LUCENE-1448
   public void testEndOffsetPositionStandardEmptyField() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setAnalyzer(new StandardAnalyzer(
+        TEST_VERSION_CURRENT)));
     Document doc = new Document();
     Field f = new Field("field", "", Field.Store.NO,
                         Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
@@ -4293,7 +4269,9 @@ public class TestIndexWriter extends Luc
   // LUCENE-1448
   public void testEndOffsetPositionStandardEmptyField2() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT).setAnalyzer(new StandardAnalyzer(
+        TEST_VERSION_CURRENT)));
     Document doc = new Document();
 
     Field f = new Field("field", "abcd", Field.Store.NO,
@@ -4335,7 +4313,7 @@ public class TestIndexWriter extends Luc
       out.writeByte((byte) 42);
       out.close();
 
-      new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED).close();
+      new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT)).close();
 
       assertTrue(dir.fileExists("myrandomfile"));
 
@@ -4351,8 +4329,7 @@ public class TestIndexWriter extends Luc
 
   public void testDeadlock() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
-    writer.setMaxBufferedDocs(2);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
     Document doc = new Document();
     doc.add(new Field("content", "aaa bbb ccc ddd eee fff ggg hhh iii", Field.Store.YES,
                       Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
@@ -4363,7 +4340,7 @@ public class TestIndexWriter extends Luc
     // index has 2 segments
 
     MockRAMDirectory dir2 = new MockRAMDirectory();
-    IndexWriter writer2 = new IndexWriter(dir2, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
+    IndexWriter writer2 = new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT));
     writer2.addDocument(doc);
     writer2.close();
 
@@ -4401,7 +4378,8 @@ public class TestIndexWriter extends Luc
             if (w != null) {
               w.close();
             }
-            w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
+            w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT).setMaxBufferedDocs(2));
+            ((LogMergePolicy) w.getMergePolicy()).setMergeFactor(2);
 
             //((ConcurrentMergeScheduler) w.getMergeScheduler()).setSuppressExceptions();
             if (!first && !allowInterrupt) {
@@ -4410,8 +4388,6 @@ public class TestIndexWriter extends Luc
               allowInterrupt = true;
             }
 
-            w.setMaxBufferedDocs(2);
-            w.setMergeFactor(2);
             Document doc = new Document();
             doc.add(new Field("field", "some text contents", Field.Store.YES, Field.Index.ANALYZED));
             for(int i=0;i<100;i++) {
@@ -4510,7 +4486,7 @@ public class TestIndexWriter extends Luc
 
   public void testIndexStoreCombos() throws Exception {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     byte[] b = new byte[50];
     for(int i=0;i<50;i++)
       b[i] = (byte) (i+77);
@@ -4572,7 +4548,7 @@ public class TestIndexWriter extends Luc
   // LUCENE-1727: make sure doc fields are stored in order
   public void testStoredFieldsOrder() throws Throwable {
     Directory d = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(d, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter w = new IndexWriter(d, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     doc.add(new Field("zzz", "a b c", Field.Store.YES, Field.Index.NO));
     doc.add(new Field("aaa", "a b c", Field.Store.YES, Field.Index.NO));
@@ -4604,7 +4580,7 @@ public class TestIndexWriter extends Luc
   public void testEmbeddedFFFF() throws Throwable {
 
     Directory d = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(d, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
+    IndexWriter w = new IndexWriter(d, new IndexWriterConfig(TEST_VERSION_CURRENT));
     Document doc = new Document();
     doc.add(new Field("field", "a a\uffffb", Field.Store.NO, Field.Index.ANALYZED));
     w.addDocument(doc);
@@ -4619,8 +4595,10 @@ public class TestIndexWriter extends Luc
 
   public void testNoDocsIndex() throws Throwable {
     Directory dir = new MockRAMDirectory();
-    IndexWriter writer = new IndexWriter(dir, new SimpleAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
-    writer.setUseCompoundFile(false);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
+    LogMergePolicy lmp = (LogMergePolicy) writer.getMergePolicy();
+    lmp.setUseCompoundFile(false);
+    lmp.setUseCompoundDocStore(false);
     ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
     writer.setInfoStream(new PrintStream(bos));
     writer.addDocument(new Document());
@@ -4637,7 +4615,7 @@ public class TestIndexWriter extends Luc
     final int NUM_THREADS = 5;
     final double RUN_SEC = 0.5;
     final Directory dir = new MockRAMDirectory();
-    final IndexWriter w = new IndexWriter(dir, new SimpleAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
+    final IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
     w.commit();
     final AtomicBoolean failed = new AtomicBoolean();
     Thread[] threads = new Thread[NUM_THREADS];
@@ -4688,7 +4666,7 @@ public class TestIndexWriter extends Luc
 
     for(int iter=0;iter<2;iter++) {
       Directory dir = new MockRAMDirectory();
-      IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
+      IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT));
       Document doc = new Document();
       doc.add(new Field("field", "go", Field.Store.NO, Field.Index.ANALYZED));
       w.addDocument(doc);



Mime
View raw message