lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1640053 [3/10] - in /lucene/dev/branches/lucene6005/lucene: core/src/java/org/apache/lucene/document/ core/src/java/org/apache/lucene/index/ core/src/test/org/apache/lucene/ core/src/test/org/apache/lucene/codecs/compressing/ core/src/test...
Date Mon, 17 Nov 2014 00:43:47 GMT
Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java Mon Nov 17 00:43:44 2014
@@ -20,9 +20,11 @@ package org.apache.lucene.index;
 import java.io.IOException;
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.document.StoredField;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.document.TextField;
@@ -34,91 +36,29 @@ import org.junit.Test;
 public class TestConsistentFieldNumbers extends LuceneTestCase {
 
   @Test
-  public void testSameFieldNumbersAcrossSegments() throws Exception {
-    for (int i = 0; i < 2; i++) {
-      Directory dir = newDirectory();
-      IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))
-                                                   .setMergePolicy(NoMergePolicy.INSTANCE));
-
-      Document d1 = new Document();
-      d1.add(new StringField("f1", "first field", Field.Store.YES));
-      d1.add(new StringField("f2", "second field", Field.Store.YES));
-      writer.addDocument(d1);
-
-      if (i == 1) {
-        writer.close();
-        writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))
-                                         .setMergePolicy(NoMergePolicy.INSTANCE));
-      } else {
-        writer.commit();
-      }
-
-      Document d2 = new Document();
-      FieldType customType2 = new FieldType(TextField.TYPE_STORED);
-      customType2.setStoreTermVectors(true);
-      d2.add(new TextField("f2", "second field", Field.Store.NO));
-      d2.add(new Field("f1", "first field", customType2));
-      d2.add(new TextField("f3", "third field", Field.Store.NO));
-      d2.add(new TextField("f4", "fourth field", Field.Store.NO));
-      writer.addDocument(d2);
-
-      writer.close();
-
-      SegmentInfos sis = SegmentInfos.readLatestCommit(dir);
-      assertEquals(2, sis.size());
-
-      FieldInfos fis1 = IndexWriter.readFieldInfos(sis.info(0));
-      FieldInfos fis2 = IndexWriter.readFieldInfos(sis.info(1));
-
-      assertEquals("f1", fis1.fieldInfo(0).name);
-      assertEquals("f2", fis1.fieldInfo(1).name);
-      assertEquals("f1", fis2.fieldInfo(0).name);
-      assertEquals("f2", fis2.fieldInfo(1).name);
-      assertEquals("f3", fis2.fieldInfo(2).name);
-      assertEquals("f4", fis2.fieldInfo(3).name);
-
-      writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
-      writer.forceMerge(1);
-      writer.close();
-
-      sis = SegmentInfos.readLatestCommit(dir);
-      assertEquals(1, sis.size());
-
-      FieldInfos fis3 = IndexWriter.readFieldInfos(sis.info(0));
-
-      assertEquals("f1", fis3.fieldInfo(0).name);
-      assertEquals("f2", fis3.fieldInfo(1).name);
-      assertEquals("f3", fis3.fieldInfo(2).name);
-      assertEquals("f4", fis3.fieldInfo(3).name);
-
-
-      dir.close();
-    }
-  }
-
-  @Test
   public void testAddIndexes() throws Exception {
     Directory dir1 = newDirectory();
     Directory dir2 = newDirectory();
     IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(new MockAnalyzer(random()))
                                                  .setMergePolicy(NoMergePolicy.INSTANCE));
 
-    Document d1 = new Document();
-    d1.add(new TextField("f1", "first field", Field.Store.YES));
-    d1.add(new TextField("f2", "second field", Field.Store.YES));
+    FieldTypes fieldTypes = writer.getFieldTypes();
+    Document2 d1 = writer.newDocument();
+    d1.addLargeText("f1", "first field");
+    d1.addLargeText("f2", "second field");
     writer.addDocument(d1);
 
     writer.close();
     writer = new IndexWriter(dir2, newIndexWriterConfig(new MockAnalyzer(random()))
                                      .setMergePolicy(NoMergePolicy.INSTANCE));
 
-    Document d2 = new Document();
-    FieldType customType2 = new FieldType(TextField.TYPE_STORED);
-    customType2.setStoreTermVectors(true);
-    d2.add(new TextField("f2", "second field", Field.Store.YES));
-    d2.add(new Field("f1", "first field", customType2));
-    d2.add(new TextField("f3", "third field", Field.Store.YES));
-    d2.add(new TextField("f4", "fourth field", Field.Store.YES));
+    fieldTypes = writer.getFieldTypes();
+    Document2 d2 = writer.newDocument();
+    fieldTypes.enableTermVectors("f1");
+    d2.addLargeText("f2", "second field");
+    d2.addLargeText("f1", "first field");
+    d2.addLargeText("f3", "third field");
+    d2.addLargeText("f4", "fourth field");
     writer.addDocument(d2);
 
     writer.close();
@@ -153,9 +93,12 @@ public class TestConsistentFieldNumbers 
       {
         IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))
                                                     .setMergePolicy(NoMergePolicy.INSTANCE));
-        Document d = new Document();
-        d.add(new TextField("f1", "d1 first field", Field.Store.YES));
-        d.add(new TextField("f2", "d1 second field", Field.Store.YES));
+        FieldTypes fieldTypes = writer.getFieldTypes();
+        fieldTypes.disableExistsFilters();
+
+        Document2 d = writer.newDocument();
+        d.addLargeText("f1", "d1 first field");
+        d.addLargeText("f2", "d1 second field");
         writer.addDocument(d);
         writer.close();
         SegmentInfos sis = SegmentInfos.readLatestCommit(dir);
@@ -169,9 +112,9 @@ public class TestConsistentFieldNumbers 
       {
         IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))
                                                     .setMergePolicy(NoMergePolicy.INSTANCE));
-        Document d = new Document();
-        d.add(new TextField("f1", "d2 first field", Field.Store.YES));
-        d.add(new StoredField("f3", new byte[] { 1, 2, 3 }));
+        Document2 d = writer.newDocument();
+        d.addLargeText("f1", "d2 first field");
+        d.addStored("f3", new byte[] { 1, 2, 3 });
         writer.addDocument(d);
         writer.close();
         SegmentInfos sis = SegmentInfos.readLatestCommit(dir);
@@ -188,10 +131,10 @@ public class TestConsistentFieldNumbers 
       {
         IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))
                                                     .setMergePolicy(NoMergePolicy.INSTANCE));
-        Document d = new Document();
-        d.add(new TextField("f1", "d3 first field", Field.Store.YES));
-        d.add(new TextField("f2", "d3 second field", Field.Store.YES));
-        d.add(new StoredField("f3", new byte[] { 1, 2, 3, 4, 5 }));
+        Document2 d = writer.newDocument();
+        d.addLargeText("f1", "d3 first field");
+        d.addLargeText("f2", "d3 second field");
+        d.addStored("f3", new byte[] { 1, 2, 3, 4, 5 });
         writer.addDocument(d);
         writer.close();
         SegmentInfos sis = SegmentInfos.readLatestCommit(dir);
@@ -249,16 +192,27 @@ public class TestConsistentFieldNumbers 
 
     Directory dir = newDirectory();
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
+    FieldTypes fieldTypes = writer.getFieldTypes();
+    fieldTypes.disableExistsFilters();
+    for(int i=0;i<MAX_FIELDS;i++) {
+      fieldTypes.setMultiValued(""+i);
+    }
 
     for (int i = 0; i < NUM_DOCS; i++) {
-      Document d = new Document();
+      Document2 d = writer.newDocument();
       for (int j = 0; j < docs[i].length; j++) {
-        d.add(getField(docs[i][j]));
+        addField(fieldTypes, d, docs[i][j]);
       }
 
       writer.addDocument(d);
     }
 
+    Document2 d = writer.newDocument();
+
+    for(int i=0;i<MAX_FIELDS;i++) {
+      addField(fieldTypes, d, i);
+    }
+
     writer.forceMerge(1);
     writer.close();
 
@@ -267,7 +221,7 @@ public class TestConsistentFieldNumbers 
       FieldInfos fis = IndexWriter.readFieldInfos(si);
 
       for (FieldInfo fi : fis) {
-        Field expected = getField(Integer.parseInt(fi.name));
+        IndexableField expected = d.getField(fi.name);
         assertEquals(expected.fieldType().indexOptions(), fi.getIndexOptions());
         assertEquals(expected.fieldType().storeTermVectors(), fi.hasVectors());
       }
@@ -276,70 +230,8 @@ public class TestConsistentFieldNumbers 
     dir.close();
   }
 
-  private Field getField(int number) {
-    int mode = number % 16;
+  private void addField(FieldTypes fieldTypes, Document2 d, int number) {
     String fieldName = "" + number;
-    FieldType customType = new FieldType(TextField.TYPE_STORED);
-    
-    FieldType customType2 = new FieldType(TextField.TYPE_STORED);
-    customType2.setTokenized(false);
-    
-    FieldType customType3 = new FieldType(TextField.TYPE_NOT_STORED);
-    customType3.setTokenized(false);
-    
-    FieldType customType4 = new FieldType(TextField.TYPE_NOT_STORED);
-    customType4.setTokenized(false);
-    customType4.setStoreTermVectors(true);
-    customType4.setStoreTermVectorOffsets(true);
-    
-    FieldType customType5 = new FieldType(TextField.TYPE_NOT_STORED);
-    customType5.setStoreTermVectors(true);
-    customType5.setStoreTermVectorOffsets(true);
-
-    FieldType customType6 = new FieldType(TextField.TYPE_STORED);
-    customType6.setTokenized(false);
-    customType6.setStoreTermVectors(true);
-    customType6.setStoreTermVectorOffsets(true);
-
-    FieldType customType7 = new FieldType(TextField.TYPE_NOT_STORED);
-    customType7.setTokenized(false);
-    customType7.setStoreTermVectors(true);
-    customType7.setStoreTermVectorOffsets(true);
-
-    FieldType customType8 = new FieldType(TextField.TYPE_STORED);
-    customType8.setTokenized(false);
-    customType8.setStoreTermVectors(true);
-    customType8.setStoreTermVectorPositions(true);
-
-    FieldType customType9 = new FieldType(TextField.TYPE_NOT_STORED);
-    customType9.setStoreTermVectors(true);
-    customType9.setStoreTermVectorPositions(true);
-
-    FieldType customType10 = new FieldType(TextField.TYPE_STORED);
-    customType10.setTokenized(false);
-    customType10.setStoreTermVectors(true);
-    customType10.setStoreTermVectorPositions(true);
-
-    FieldType customType11 = new FieldType(TextField.TYPE_NOT_STORED);
-    customType11.setTokenized(false);
-    customType11.setStoreTermVectors(true);
-    customType11.setStoreTermVectorPositions(true);
-
-    FieldType customType12 = new FieldType(TextField.TYPE_STORED);
-    customType12.setStoreTermVectors(true);
-    customType12.setStoreTermVectorOffsets(true);
-    customType12.setStoreTermVectorPositions(true);
-
-    FieldType customType13 = new FieldType(TextField.TYPE_NOT_STORED);
-    customType13.setStoreTermVectors(true);
-    customType13.setStoreTermVectorOffsets(true);
-    customType13.setStoreTermVectorPositions(true);
-
-    FieldType customType14 = new FieldType(TextField.TYPE_STORED);
-    customType14.setTokenized(false);
-    customType14.setStoreTermVectors(true);
-    customType14.setStoreTermVectorOffsets(true);
-    customType14.setStoreTermVectorPositions(true);
 
     FieldType customType15 = new FieldType(TextField.TYPE_NOT_STORED);
     customType15.setTokenized(false);
@@ -347,24 +239,93 @@ public class TestConsistentFieldNumbers 
     customType15.setStoreTermVectorOffsets(true);
     customType15.setStoreTermVectorPositions(true);
     
+    int mode = number % 16;
     switch (mode) {
-      case 0: return new Field(fieldName, "some text", customType);
-      case 1: return new TextField(fieldName, "some text", Field.Store.NO);
-      case 2: return new Field(fieldName, "some text", customType2);
-      case 3: return new Field(fieldName, "some text", customType3);
-      case 4: return new Field(fieldName, "some text", customType4);
-      case 5: return new Field(fieldName, "some text", customType5);
-      case 6: return new Field(fieldName, "some text", customType6);
-      case 7: return new Field(fieldName, "some text", customType7);
-      case 8: return new Field(fieldName, "some text", customType8);
-      case 9: return new Field(fieldName, "some text", customType9);
-      case 10: return new Field(fieldName, "some text", customType10);
-      case 11: return new Field(fieldName, "some text", customType11);
-      case 12: return new Field(fieldName, "some text", customType12);
-      case 13: return new Field(fieldName, "some text", customType13);
-      case 14: return new Field(fieldName, "some text", customType14);
-      case 15: return new Field(fieldName, "some text", customType15);
-      default: return null;
+    case 0:
+      d.addStored(fieldName, "some text");
+      return;
+    case 1:
+      d.addLargeText(fieldName, "some text");
+      return;
+    case 2:
+      d.addAtom(fieldName, "some text");
+      return;
+    case 3:
+      fieldTypes.disableStored(fieldName);
+      d.addAtom(fieldName, "some text");
+      return;
+    case 4:
+      fieldTypes.disableStored(fieldName);
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorOffsets(fieldName);
+      d.addAtom(fieldName, "some text");
+      return;
+    case 5:
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorOffsets(fieldName);
+      d.addLargeText(fieldName, "some text");
+      return;
+    case 6:
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorOffsets(fieldName);
+      d.addAtom(fieldName, "some text");
+      return;
+    case 7:
+      fieldTypes.disableStored(fieldName);
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorOffsets(fieldName);
+      d.addAtom(fieldName, "some text");
+      return;
+    case 8:
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorPositions(fieldName);
+      d.addAtom(fieldName, "some text");
+      return;
+    case 9:
+      fieldTypes.disableStored(fieldName);
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorPositions(fieldName);
+      d.addLargeText(fieldName, "some text");
+      return;
+    case 10:
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorPositions(fieldName);
+      d.addAtom(fieldName, "some text");
+      return;
+    case 11:
+      fieldTypes.disableStored(fieldName);
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorPositions(fieldName);
+      d.addAtom(fieldName, "some text");
+      return;
+    case 12:
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorPositions(fieldName);
+      fieldTypes.enableTermVectorOffsets(fieldName);
+      d.addLargeText(fieldName, "some text");
+      return;
+    case 13:
+      fieldTypes.disableStored(fieldName);
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorPositions(fieldName);
+      fieldTypes.enableTermVectorOffsets(fieldName);
+      d.addLargeText(fieldName, "some text");
+      return;
+    case 14:
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorPositions(fieldName);
+      fieldTypes.enableTermVectorOffsets(fieldName);
+      d.addAtom(fieldName, "some text");
+      return;
+    case 15:
+      fieldTypes.disableStored(fieldName);
+      fieldTypes.enableTermVectors(fieldName);
+      fieldTypes.enableTermVectorPositions(fieldName);
+      fieldTypes.enableTermVectorOffsets(fieldName);
+      d.addAtom(fieldName, "some text");
+      return;
+    default:
+      assert false;
     }
   }
 }

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCrash.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCrash.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCrash.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCrash.java Mon Nov 17 00:43:44 2014
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.Random;
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.store.Directory;
@@ -42,11 +43,12 @@ public class TestCrash extends LuceneTes
       writer.commit();
     }
     
-    Document doc = new Document();
-    doc.add(newTextField("content", "aaa", Field.Store.NO));
-    doc.add(newTextField("id", "0", Field.Store.NO));
-    for(int i=0;i<157;i++)
+    Document2 doc = writer.newDocument();
+    doc.addLargeText("content", "aaa");
+    doc.addLargeText("id", "0");
+    for(int i=0;i<157;i++) {
       writer.addDocument(doc);
+    }
 
     return writer;
   }

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java Mon Nov 17 00:43:44 2014
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.nio.file.Path;
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.search.IndexSearcher;
@@ -66,12 +67,12 @@ public class TestCrashCausesCorruptIndex
     IndexWriter indexWriter = new IndexWriter(crashAfterCreateOutput,
                                               newIndexWriterConfig(new MockAnalyzer(random())));
             
-    indexWriter.addDocument(getDocument());
+    indexWriter.addDocument(getDocument(indexWriter));
     // writes segments_1:
     indexWriter.commit();
             
     crashAfterCreateOutput.setCrashAfterCreateOutput("pending_segments_2");
-    indexWriter.addDocument(getDocument());
+    indexWriter.addDocument(getDocument(indexWriter));
     try {
       // tries to write segments_2 but hits fake exc:
       indexWriter.commit();
@@ -99,7 +100,7 @@ public class TestCrashCausesCorruptIndex
             
     // currently the test fails above.
     // however, to test the fix, the following lines should pass as well.
-    indexWriter.addDocument(getDocument());
+    indexWriter.addDocument(getDocument(indexWriter));
     indexWriter.close();
     assertFalse(slowFileExists(realDirectory, "segments_2"));
     realDirectory.close();
@@ -124,9 +125,9 @@ public class TestCrashCausesCorruptIndex
   /**
    * Gets a document with content "my dog has fleas".
    */
-  private Document getDocument() {
-    Document document = new Document();
-    document.add(newTextField(TEXT_FIELD, "my dog has fleas", Field.Store.NO));
+  private Document2 getDocument(IndexWriter w) {
+    Document2 document = w.newDocument();
+    document.addLargeText(TEXT_FIELD, "my dog has fleas");
     return document;
   }
     

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java Mon Nov 17 00:43:44 2014
@@ -26,8 +26,10 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
@@ -656,6 +658,8 @@ public class TestDeletionPolicy extends 
         mp = conf.getMergePolicy();
         mp.setNoCFSRatio(useCompoundFile ? 1.0 : 0.0);
         writer = new IndexWriter(dir, conf);
+        FieldTypes fieldTypes = writer.getFieldTypes();
+
         policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
         for(int j=0;j<17;j++) {
           addDocWithID(writer, i*(N+1)+j);
@@ -667,7 +671,7 @@ public class TestDeletionPolicy extends 
           .setMergePolicy(NoMergePolicy.INSTANCE);
         writer = new IndexWriter(dir, conf);
         policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
-        writer.deleteDocuments(new Term("id", "" + (i*(N+1)+3)));
+        writer.deleteDocuments(fieldTypes.newIntTerm("id", (i*(N+1)+3)));
         // this is a commit
         writer.close();
         IndexReader reader = DirectoryReader.open(dir);
@@ -737,16 +741,15 @@ public class TestDeletionPolicy extends 
   }
 
   private void addDocWithID(IndexWriter writer, int id) throws IOException {
-    Document doc = new Document();
-    doc.add(newTextField("content", "aaa", Field.Store.NO));
-    doc.add(newStringField("id", "" + id, Field.Store.NO));
+    Document2 doc = writer.newDocument();
+    doc.addLargeText("content", "aaa");
+    doc.addUniqueInt("id", id);
     writer.addDocument(doc);
   }
   
-  private void addDoc(IndexWriter writer) throws IOException
-  {
-    Document doc = new Document();
-    doc.add(newTextField("content", "aaa", Field.Store.NO));
+  private void addDoc(IndexWriter writer) throws IOException {
+    Document2 doc = writer.newDocument();
+    doc.addLargeText("content", "aaa");
     writer.addDocument(doc);
   }
 }

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java Mon Nov 17 00:43:44 2014
@@ -617,7 +617,9 @@ public class TestDirectoryReader extends
       while(enum1.next() != null) {
         assertEquals("Different terms", enum1.term(), enum2.next());
         DocsAndPositionsEnum tp1 = enum1.docsAndPositions(liveDocs, null);
+        assertNotNull("no positions for field=" + field1 + " term=" + enum1.term(), tp1);
         DocsAndPositionsEnum tp2 = enum2.docsAndPositions(liveDocs, null);
+        assertNotNull("no positions field=" + field1 + " term=" + enum2.term(), tp2);
 
         while(tp1.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
           assertTrue(tp2.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java Mon Nov 17 00:43:44 2014
@@ -33,6 +33,7 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -111,19 +112,12 @@ public class TestDirectoryReaderReopen e
     DirectoryReader reader = DirectoryReader.open(dir);
     try {
       int M = 3;
-      FieldType customType = new FieldType(TextField.TYPE_STORED);
-      customType.setTokenized(false);
-      FieldType customType2 = new FieldType(TextField.TYPE_STORED);
-      customType2.setTokenized(false);
-      customType2.setOmitNorms(true);
-      FieldType customType3 = new FieldType();
-      customType3.setStored(true);
       for (int i=0; i<4; i++) {
         for (int j=0; j<M; j++) {
-          Document doc = new Document();
-          doc.add(newField("id", i+"_"+j, customType));
-          doc.add(newField("id2", i+"_"+j, customType2));
-          doc.add(newField("id3", i+"_"+j, customType3));
+          Document2 doc = iwriter.newDocument();
+          doc.addAtom("id", i+"_"+j);
+          doc.addAtom("id2", i+"_"+j);
+          doc.addStored("id3", i+"_"+j);
           iwriter.addDocument(doc);
           if (i>0) {
             int k = i-1;
@@ -205,8 +199,10 @@ public class TestDirectoryReaderReopen e
     // NOTE: this also controls the number of threads!
     final int n = TestUtil.nextInt(random(), 20, 40);
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
+    FieldTypes fieldTypes = writer.getFieldTypes();
+    fieldTypes.disableExistsFilters();
     for (int i = 0; i < n; i++) {
-      writer.addDocument(createDocument(i, 3));
+      writer.addDocument(createDocument(writer, i, 3));
     }
     writer.forceMerge(1);
     writer.close();
@@ -215,7 +211,7 @@ public class TestDirectoryReaderReopen e
       @Override
       protected void modifyIndex(int i) throws IOException {
        IndexWriter modifier = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())));
-       modifier.addDocument(createDocument(n + i, 6));
+       modifier.addDocument(createDocument(modifier, n + i, 6));
        modifier.close();
       }
 
@@ -436,9 +432,11 @@ public class TestDirectoryReaderReopen e
     IndexWriter.unlock(dir);
     IndexWriter w = new IndexWriter(dir, LuceneTestCase.newIndexWriterConfig(random, new MockAnalyzer(random))
         .setMergePolicy(new LogDocMergePolicy()));
+    FieldTypes fieldTypes = w.getFieldTypes();
+    fieldTypes.disableExistsFilters();
     
     for (int i = 0; i < 100; i++) {
-      w.addDocument(createDocument(i, 4));
+      w.addDocument(createDocument(w, i, 4));
       if (multiSegment && (i % 10) == 0) {
         w.commit();
       }
@@ -459,23 +457,18 @@ public class TestDirectoryReaderReopen e
     r.close();
   }
 
-  public static Document createDocument(int n, int numFields) {
+  public static Document2 createDocument(IndexWriter w, int n, int numFields) {
     StringBuilder sb = new StringBuilder();
-    Document doc = new Document();
+    Document2 doc = w.newDocument();
     sb.append("a");
     sb.append(n);
-    FieldType customType2 = new FieldType(TextField.TYPE_STORED);
-    customType2.setTokenized(false);
-    customType2.setOmitNorms(true);
-    FieldType customType3 = new FieldType();
-    customType3.setStored(true);
-    doc.add(new TextField("field1", sb.toString(), Field.Store.YES));
-    doc.add(new Field("fielda", sb.toString(), customType2));
-    doc.add(new Field("fieldb", sb.toString(), customType3));
+    doc.addLargeText("field1", sb.toString());
+    doc.addLargeText("fielda", sb.toString());
+    doc.addStored("fieldb", sb.toString());
     sb.append(" b");
     sb.append(n);
     for (int i = 1; i < numFields; i++) {
-      doc.add(new TextField("field" + (i+1), sb.toString(), Field.Store.YES));
+      doc.addLargeText("field" + (i+1), sb.toString());
     }
     return doc;
   }
@@ -500,16 +493,16 @@ public class TestDirectoryReaderReopen e
       }
       case 2: {
         IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())));
-        w.addDocument(createDocument(101, 4));
+        w.addDocument(createDocument(w, 101, 4));
         w.forceMerge(1);
-        w.addDocument(createDocument(102, 4));
-        w.addDocument(createDocument(103, 4));
+        w.addDocument(createDocument(w, 102, 4));
+        w.addDocument(createDocument(w, 103, 4));
         w.close();
         break;
       }
       case 3: {
         IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())));
-        w.addDocument(createDocument(101, 4));
+        w.addDocument(createDocument(w, 101, 4));
         w.close();
         break;
       }
@@ -552,9 +545,10 @@ public class TestDirectoryReaderReopen e
             .setMaxBufferedDocs(-1)
             .setMergePolicy(newLogMergePolicy(10))
     );
+    FieldTypes fieldTypes = writer.getFieldTypes();
     for(int i=0;i<4;i++) {
-      Document doc = new Document();
-      doc.add(newStringField("id", ""+i, Field.Store.NO));
+      Document2 doc = writer.newDocument();
+      doc.addUniqueInt("id", i);
       writer.addDocument(doc);
       Map<String,String> data = new HashMap<>();
       data.put("index", i+"");
@@ -562,7 +556,7 @@ public class TestDirectoryReaderReopen e
       writer.commit();
     }
     for(int i=0;i<4;i++) {
-      writer.deleteDocuments(new Term("id", ""+i));
+      writer.deleteDocuments(fieldTypes.newIntTerm("id", i));
       Map<String,String> data = new HashMap<>();
       data.put("index", (4+i)+"");
       writer.setCommitData(data);
@@ -604,8 +598,8 @@ public class TestDirectoryReaderReopen e
 
     // Can't use RIW because it randomly commits:
     IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
-    Document doc = new Document();
-    doc.add(newStringField("field", "value", Field.Store.NO));
+    Document2 doc = w.newDocument();
+    doc.addAtom("field", "value");
     w.addDocument(doc);
     w.commit();
     List<IndexCommit> commits = DirectoryReader.listCommits(dir);
@@ -633,11 +627,11 @@ public class TestDirectoryReaderReopen e
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     iwc.setCodec(TestUtil.getDefaultCodec());
     IndexWriter w = new IndexWriter(dir, iwc);
-    Document doc = new Document();
-    doc.add(newStringField("id", "id", Field.Store.NO));
+    Document2 doc = w.newDocument();
+    doc.addAtom("id", "id");
     w.addDocument(doc);
-    doc = new Document();
-    doc.add(newStringField("id", "id2", Field.Store.NO));
+    doc = w.newDocument();
+    doc.addAtom("id", "id2");
     w.addDocument(doc);
     w.commit();
 
@@ -698,11 +692,11 @@ public class TestDirectoryReaderReopen e
     Directory dir = new RAMDirectory();
 
     IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())));
-    Document doc = new Document();
-    doc.add(newStringField("id", "id", Field.Store.NO));
+    Document2 doc = w.newDocument();
+    doc.addAtom("id", "id");
     w.addDocument(doc);
-    doc = new Document();
-    doc.add(newStringField("id", "id2", Field.Store.NO));
+    doc = w.newDocument();
+    doc.addAtom("id", "id2");
     w.addDocument(doc);
     w.deleteDocuments(new Term("id", "id"));
     w.commit();
@@ -717,16 +711,16 @@ public class TestDirectoryReaderReopen e
     }
 
     w = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())));
-    doc = new Document();
-    doc.add(newStringField("id", "id", Field.Store.NO));
-    doc.add(new NumericDocValuesField("ndv", 13));
+    doc = w.newDocument();
+    doc.addAtom("id", "id");
+    doc.addInt("ndv", 13);
     w.addDocument(doc);
-    doc = new Document();
-    doc.add(newStringField("id", "id2", Field.Store.NO));
+    doc = w.newDocument();
+    doc.addAtom("id", "id2");
     w.addDocument(doc);
     w.commit();
-    doc = new Document();
-    doc.add(newStringField("id", "id2", Field.Store.NO));
+    doc = w.newDocument();
+    doc.addAtom("id", "id2");
     w.addDocument(doc);
     w.updateNumericDocValue(new Term("id", "id"), "ndv", 17L);
     w.commit();
@@ -748,11 +742,11 @@ public class TestDirectoryReaderReopen e
     Directory dir = new RAMDirectory();
 
     IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())));
-    Document doc = new Document();
-    doc.add(newStringField("id", "id", Field.Store.NO));
+    Document2 doc = w.newDocument();
+    doc.addAtom("id", "id");
     w.addDocument(doc);
-    doc = new Document();
-    doc.add(newStringField("id", "id2", Field.Store.NO));
+    doc = w.newDocument();
+    doc.addAtom("id", "id2");
     w.addDocument(doc);
     w.deleteDocuments(new Term("id", "id"));
     w.commit();
@@ -767,13 +761,13 @@ public class TestDirectoryReaderReopen e
     }
 
     w = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())));
-    doc = new Document();
-    doc.add(newStringField("id", "id", Field.Store.NO));
-    doc.add(new NumericDocValuesField("ndv", 13));
+    doc = w.newDocument();
+    doc.addAtom("id", "id");
+    doc.addInt("ndv", 13);
     w.addDocument(doc);
     w.commit();
-    doc = new Document();
-    doc.add(newStringField("id", "id2", Field.Store.NO));
+    doc = w.newDocument();
+    doc.addAtom("id", "id2");
     w.addDocument(doc);
     w.commit();
     w.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDoc.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDoc.java Mon Nov 17 00:43:44 2014
@@ -33,6 +33,7 @@ import java.util.LinkedList;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.document.TextField;
@@ -130,6 +131,8 @@ public class TestDoc extends LuceneTestC
               setMaxBufferedDocs(-1).
               setMergePolicy(newLogMergePolicy(10))
       );
+      FieldTypes fieldTypes = writer.getFieldTypes();
+      fieldTypes.disableExistsFilters();
 
       SegmentCommitInfo si1 = indexDoc(writer, "test.txt");
       printSegment(out, si1);
@@ -175,6 +178,9 @@ public class TestDoc extends LuceneTestC
               setMergePolicy(newLogMergePolicy(10))
       );
 
+      fieldTypes = writer.getFieldTypes();
+      fieldTypes.disableExistsFilters();
+
       si1 = indexDoc(writer, "test.txt");
       printSegment(out, si1);
 
@@ -202,9 +208,9 @@ public class TestDoc extends LuceneTestC
    private SegmentCommitInfo indexDoc(IndexWriter writer, String fileName)
      throws Exception {
      Path path = workDir.resolve(fileName);
-     Document doc = new Document();
+     Document2 doc = writer.newDocument();
      InputStreamReader is = new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8);
-     doc.add(new TextField("contents", is));
+     doc.addLargeText("contents", is);
      writer.addDocument(doc);
      writer.commit();
      is.close();
@@ -261,7 +267,6 @@ public class TestDoc extends LuceneTestC
           out.println("    DF=" + tis.docFreq());
 
           DocsAndPositionsEnum positions = tis.docsAndPositions(reader.getLiveDocs(), null);
-
           while (positions.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
             out.print(" doc=" + positions.docID());
             out.print(" TF=" + positions.freq());

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java Mon Nov 17 00:43:44 2014
@@ -17,8 +17,10 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.FixedBitSet;
@@ -34,7 +36,7 @@ public class TestDocCount extends Lucene
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
     int numDocs = atLeast(100);
     for (int i = 0; i < numDocs; i++) {
-      iw.addDocument(doc());
+      iw.addDocument(doc(iw));
     }
     IndexReader ir = iw.getReader();
     verifyCount(ir);
@@ -47,11 +49,14 @@ public class TestDocCount extends Lucene
     dir.close();
   }
   
-  private Document doc() {
-    Document doc = new Document();
+  private Document2 doc(RandomIndexWriter w) {
+    Document2 doc = w.newDocument();
     int numFields = TestUtil.nextInt(random(), 1, 10);
+    FieldTypes fieldTypes = w.getFieldTypes();
     for (int i = 0; i < numFields; i++) {
-      doc.add(newStringField("" + TestUtil.nextInt(random(), 'a', 'z'), "" + TestUtil.nextInt(random(), 'a', 'z'), Field.Store.NO));
+      String fieldName = "" + TestUtil.nextInt(random(), 'a', 'z');
+      fieldTypes.setMultiValued(fieldName);
+      doc.addAtom(fieldName, "" + TestUtil.nextInt(random(), 'a', 'z'));
     }
     return doc;
   }

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java Mon Nov 17 00:43:44 2014
@@ -17,10 +17,15 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.MockTokenizer;
 import org.apache.lucene.analysis.TokenFilter;
 import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
@@ -30,15 +35,10 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.lucene.util.PrintStreamInfoStream;
 import org.junit.Test;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-
 /**
  * Test adding to the info stream when there's an exception thrown during field analysis.
  */
 public class TestDocInverterPerFieldErrorInfo extends LuceneTestCase {
-  private static final FieldType storedTextType = new FieldType(TextField.TYPE_NOT_STORED);
 
   private static class BadNews extends RuntimeException {
     private BadNews(String message) {
@@ -67,15 +67,14 @@ public class TestDocInverterPerFieldErro
   @Test
   public void testInfoStreamGetsFieldName() throws Exception {
     Directory dir = newDirectory();
-    IndexWriter writer;
     IndexWriterConfig c = new IndexWriterConfig(new ThrowingAnalyzer());
     final ByteArrayOutputStream infoBytes = new ByteArrayOutputStream();
     PrintStream infoPrintStream = new PrintStream(infoBytes, true, IOUtils.UTF_8);
     PrintStreamInfoStream printStreamInfoStream = new PrintStreamInfoStream(infoPrintStream);
     c.setInfoStream(printStreamInfoStream);
-    writer = new IndexWriter(dir, c);
-    Document doc = new Document();
-    doc.add(newField("distinctiveFieldName", "aaa ", storedTextType));
+    IndexWriter writer = new IndexWriter(dir, c);
+    Document2 doc = writer.newDocument();
+    doc.addLargeText("distinctiveFieldName", "aaa ");
     try {
       writer.addDocument(doc);
       fail("Failed to fail.");
@@ -92,15 +91,14 @@ public class TestDocInverterPerFieldErro
   @Test
   public void testNoExtraNoise() throws Exception {
     Directory dir = newDirectory();
-    IndexWriter writer;
     IndexWriterConfig c = new IndexWriterConfig(new ThrowingAnalyzer());
     final ByteArrayOutputStream infoBytes = new ByteArrayOutputStream();
     PrintStream infoPrintStream = new PrintStream(infoBytes, true, IOUtils.UTF_8);
     PrintStreamInfoStream printStreamInfoStream = new PrintStreamInfoStream(infoPrintStream);
     c.setInfoStream(printStreamInfoStream);
-    writer = new IndexWriter(dir, c);
-    Document doc = new Document();
-    doc.add(newField("boringFieldName", "aaa ", storedTextType));
+    IndexWriter writer = new IndexWriter(dir, c);
+    Document2 doc = writer.newDocument();
+    doc.addLargeText("boringFieldName", "aaa ");
     try {
       writer.addDocument(doc);
     } catch(BadNews badNews) {

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java Mon Nov 17 00:43:44 2014
@@ -24,12 +24,13 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Document2;
+import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.document.TextField;
+import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -160,6 +161,9 @@ public class TestDocValuesIndexing exten
   public void testLengthPrefixAcrossTwoPages() throws Exception {
     Directory d = newDirectory();
     IndexWriter w = new IndexWriter(d, new IndexWriterConfig(new MockAnalyzer(random())));
+    FieldTypes fieldTypes = w.getFieldTypes();
+    fieldTypes.setIndexOptions("field", IndexOptions.NONE);
+
     Document2 doc = w.newDocument();
     byte[] bytes = new byte[32764];
     BytesRef b = new BytesRef();
@@ -853,62 +857,4 @@ public class TestDocValuesIndexing exten
     r.close();
     dir.close();
   }
-
-  // nocommit must cut this over to low-schema:
-  @Ignore
-  public void testSameFieldNameForPostingAndDocValue() throws Exception {
-    // LUCENE-5192: FieldInfos.Builder neglected to update
-    // globalFieldNumbers.docValuesType map if the field existed, resulting in
-    // potentially adding the same field with different DV types.
-    Directory dir = newDirectory();
-    IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
-    IndexWriter writer = new IndexWriter(dir, conf);
-    
-    Document2 doc = writer.newDocument();
-    doc.addAtom("f", "mock-value");
-    doc.addInt("f", 5);
-    writer.addDocument(doc);
-    writer.commit();
-    
-    doc = writer.newDocument();
-    doc.addAtom("f", new BytesRef("mock"));
-    try {
-      writer.addDocument(doc);
-      fail("should not have succeeded to add a field with different DV type than what already exists");
-    } catch (IllegalArgumentException e) {
-      writer.rollback();
-    }
-    
-    dir.close();
-  }
-
-  // LUCENE-6049
-  // nocommit must cut this over to low-schema:
-  @Ignore
-  public void testExcIndexingDocBeforeDocValues() throws Exception {
-    Directory dir = newDirectory();
-    IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
-    IndexWriter w = new IndexWriter(dir, iwc);
-    Document doc = new Document();
-    FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
-    ft.setDocValuesType(DocValuesType.SORTED);
-    ft.freeze();
-    Field field = new Field("test", "value", ft);
-    field.setTokenStream(new TokenStream() {
-        @Override
-        public boolean incrementToken() {
-          throw new RuntimeException("no");
-        }
-      });
-    doc.add(field);
-    try {
-      w.addDocument(doc);
-      fail("did not hit exception");
-    } catch (RuntimeException re) {
-      // expected
-    }
-    w.addDocument(new Document());
-    w.close();
-    dir.close();
-  }
 }

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java Mon Nov 17 00:43:44 2014
@@ -20,9 +20,11 @@ package org.apache.lucene.index;
 import java.io.IOException;
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
@@ -56,18 +58,17 @@ public class TestExceedMaxTermLength ext
     
     IndexWriter w = new IndexWriter
       (dir, newIndexWriterConfig(random(), new MockAnalyzer(random())));
+    FieldTypes fieldTypes = w.getFieldTypes();
     try {
       final FieldType ft = new FieldType();
       ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
       ft.setStored(random().nextBoolean());
       ft.freeze();
       
-      final Document doc = new Document();
+      final Document2 doc = w.newDocument();
       if (random().nextBoolean()) {
         // totally ok short field value
-        doc.add(new Field(TestUtil.randomSimpleString(random(), 1, 10),
-                          TestUtil.randomSimpleString(random(), 1, 10),
-                          ft));
+        doc.addLargeText(TestUtil.randomSimpleString(random(), 1, 10), TestUtil.randomSimpleString(random(), 1, 10));
       }
       // problematic field
       final String name = TestUtil.randomSimpleString(random(), 1, 50);
@@ -77,11 +78,9 @@ public class TestExceedMaxTermLength ext
       final Field f = new Field(name, value, ft);
       if (random().nextBoolean()) {
         // totally ok short field value
-        doc.add(new Field(TestUtil.randomSimpleString(random(), 1, 10),
-                          TestUtil.randomSimpleString(random(), 1, 10),
-                          ft));
+        doc.addLargeText(TestUtil.randomSimpleString(random(), 1, 10), TestUtil.randomSimpleString(random(), 1, 10));
       }
-      doc.add(f);
+      doc.addLargeText(name, value);
       
       try {
         w.addDocument(doc);

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestExitableDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestExitableDirectoryReader.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestExitableDirectoryReader.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestExitableDirectoryReader.java Mon Nov 17 00:43:44 2014
@@ -17,7 +17,10 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
+import java.io.IOException;
+
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.ExitableDirectoryReader.ExitingReaderException;
@@ -28,8 +31,6 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
 
-import java.io.IOException;
-
 /**
  * Test that uses a default/lucene Implementation of {@link QueryTimeout}
  * to exit out long running queries that take too long to iterate over Terms.
@@ -96,16 +97,16 @@ public class TestExitableDirectoryReader
     Directory directory = newDirectory();
     IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(new MockAnalyzer(random())));
 
-    Document d1 = new Document();
-    d1.add(newTextField("default", "one two", Field.Store.YES));
+    Document2 d1 = writer.newDocument();
+    d1.addLargeText("default", "one two");
     writer.addDocument(d1);
 
-    Document d2 = new Document();
-    d2.add(newTextField("default", "one three", Field.Store.YES));
+    Document2 d2 = writer.newDocument();
+    d2.addLargeText("default", "one three");
     writer.addDocument(d2);
 
-    Document d3 = new Document();
-    d3.add(newTextField("default", "ones two four", Field.Store.YES));
+    Document2 d3 = writer.newDocument();
+    d3.addLargeText("default", "ones two four");
     writer.addDocument(d3);
 
     writer.commit();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFilterLeafReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFilterLeafReader.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFilterLeafReader.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFilterLeafReader.java Mon Nov 17 00:43:44 2014
@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.search.DocIdSetIterator;
@@ -118,16 +119,16 @@ public class TestFilterLeafReader extend
 
     IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(new MockAnalyzer(random())));
 
-    Document d1 = new Document();
-    d1.add(newTextField("default", "one two", Field.Store.YES));
+    Document2 d1 = writer.newDocument();
+    d1.addLargeText("default", "one two");
     writer.addDocument(d1);
 
-    Document d2 = new Document();
-    d2.add(newTextField("default", "one three", Field.Store.YES));
+    Document2 d2 = writer.newDocument();
+    d2.addLargeText("default", "one three");
     writer.addDocument(d2);
 
-    Document d3 = new Document();
-    d3.add(newTextField("default", "two four", Field.Store.YES));
+    Document2 d3 = writer.newDocument();
+    d3.addLargeText("default", "two four");
     writer.addDocument(d3);
 
     writer.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFlex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFlex.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFlex.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFlex.java Mon Nov 17 00:43:44 2014
@@ -38,11 +38,11 @@ public class TestFlex extends LuceneTest
 
     for(int iter=0;iter<2;iter++) {
       if (iter == 0) {
-        Document doc = new Document();
-        doc.add(newTextField("field1", "this is field1", Field.Store.NO));
-        doc.add(newTextField("field2", "this is field2", Field.Store.NO));
-        doc.add(newTextField("field3", "aaa", Field.Store.NO));
-        doc.add(newTextField("field4", "bbb", Field.Store.NO));
+        Document2 doc = w.newDocument();
+        doc.addLargeText("field1", "this is field1");
+        doc.addLargeText("field2", "this is field2");
+        doc.addLargeText("field3", "aaa");
+        doc.addLargeText("field4", "bbb");
         for(int i=0;i<DOC_COUNT;i++) {
           w.addDocument(doc);
         }
@@ -65,8 +65,8 @@ public class TestFlex extends LuceneTest
     Directory d = newDirectory();
     IndexWriter w = new IndexWriter(d, newIndexWriterConfig(new MockAnalyzer(random()))
                                          .setCodec(TestUtil.alwaysPostingsFormat(TestUtil.getDefaultPostingsFormat())));
-    Document doc = new Document();
-    doc.add(newTextField("f", "a b c", Field.Store.NO));
+    Document2 doc = w.newDocument();
+    doc.addLargeText("f", "a b c");
     w.addDocument(doc);
     w.forceMerge(1);
     DirectoryReader r = w.getReader();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java Mon Nov 17 00:43:44 2014
@@ -18,6 +18,7 @@ package org.apache.lucene.index;
  */
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.TextField;
@@ -48,8 +49,8 @@ public class TestForTooMuchCloning exten
         sb.append(TestUtil.randomRealisticUnicodeString(random()));
         sb.append(' ');
       }
-      final Document doc = new Document();
-      doc.add(new TextField("field", sb.toString(), Field.Store.NO));
+      Document2 doc = w.newDocument();
+      doc.addLargeText("field", sb.toString());
       w.addDocument(doc);
     }
     final IndexReader r = w.getReader();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java Mon Nov 17 00:43:44 2014
@@ -22,6 +22,7 @@ import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -210,11 +211,10 @@ public class TestIndexFileDeleter extend
     out.close();
   }
 
-  private void addDoc(IndexWriter writer, int id) throws IOException
-  {
-    Document doc = new Document();
-    doc.add(newTextField("content", "aaa", Field.Store.NO));
-    doc.add(newStringField("id", Integer.toString(id), Field.Store.NO));
+  private void addDoc(IndexWriter writer, int id) throws IOException {
+    Document2 doc = writer.newDocument();
+    doc.addLargeText("content", "aaa");
+    doc.addAtom("id", Integer.toString(id));
     writer.addDocument(doc);
   }
   
@@ -245,7 +245,7 @@ public class TestIndexFileDeleter extend
     });
     
     IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(null));
-    iw.addDocument(new Document());
+    iw.addDocument(iw.newDocument());
     // stop virus scanner
     stopScanning.set(true);
     iw.commit();
@@ -321,7 +321,7 @@ public class TestIndexFileDeleter extend
     
     // ensure we write _4 segment next
     IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(null));
-    iw.addDocument(new Document());
+    iw.addDocument(iw.newDocument());
     iw.commit();
     iw.close();
     sis = SegmentInfos.readLatestCommit(dir);
@@ -336,7 +336,7 @@ public class TestIndexFileDeleter extend
     
     // initial commit
     IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(null));
-    iw.addDocument(new Document());
+    iw.addDocument(iw.newDocument());
     iw.commit();
     iw.close();   
     
@@ -383,7 +383,7 @@ public class TestIndexFileDeleter extend
     
     // initial commit
     IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(null));
-    iw.addDocument(new Document());
+    iw.addDocument(iw.newDocument());
     iw.commit();
     iw.close();   
     
@@ -466,8 +466,8 @@ public class TestIndexFileDeleter extend
         } else if (random().nextInt(10) == 7) {
           w.getReader().close();
         } else {
-          Document doc = new Document();
-          doc.add(newTextField("field", "some text", Field.Store.NO));
+          Document2 doc = w.newDocument();
+          doc.addLargeText("field", "some text");
           w.addDocument(doc);
         }
       } catch (IOException ioe) {

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java?rev=1640053&r1=1640052&r2=1640053&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java Mon Nov 17 00:43:44 2014
@@ -98,7 +98,7 @@ public class TestIndexReaderClose extend
     RandomIndexWriter w = new RandomIndexWriter(random(), newDirectory());
     final int numDocs = TestUtil.nextInt(random(), 1, 5);
     for (int i = 0; i < numDocs; ++i) {
-      w.addDocument(new Document());
+      w.addDocument(w.newDocument());
       if (random().nextBoolean()) {
         w.commit();
       }



Mime
View raw message