You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2014/11/30 12:07:19 UTC

svn commit: r1642535 [14/19] - in /lucene/dev/branches/lucene6005/lucene: analysis/common/src/java/org/apache/lucene/collation/ analysis/common/src/test/org/apache/lucene/analysis/core/ analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/...

Modified: lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java (original)
+++ lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java Sun Nov 30 11:07:09 2014
@@ -28,13 +28,8 @@ import java.util.Map;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.MockTokenizer;
-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.StringField;
-import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.IndexOptions;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.RandomIndexWriter;
@@ -59,15 +54,12 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test. Just a test highlighting from postings. Feel free to ignore.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test. Just a test highlighting from postings. Feel free to ignore.");
     iw.addDocument(doc);
-    body.setStringValue("Highlighting the first term. Hope it works.");
+
+    doc = iw.newDocument();
+    doc.addLargeText("body", "Highlighting the first term. Hope it works.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -129,15 +121,10 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    final FieldType fieldType = new FieldType(TextField.TYPE_STORED);
-    fieldType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    final Field body = new Field("body", bodyText, fieldType);
-    
-    Document doc = new Document();
-    doc.add(body);
-    
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", bodyText);
     iw.addDocument(doc);
-    
+
     IndexReader ir = iw.getReader();
     iw.close();
     
@@ -160,19 +147,14 @@ public class TestPostingsHighlighter ext
   // simple test highlighting last word.
   public void testHighlightLastWord() throws Exception {
     Directory dir = newDirectory();
-    IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
+    IndexWriterConfig iwc = newIndexWriterConfig();
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test");
     iw.addDocument(doc);
-    
+
     IndexReader ir = iw.getReader();
     iw.close();
     
@@ -197,15 +179,12 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test.");
     iw.addDocument(doc);
-    body.setStringValue("Test a one sentence document.");
+
+    doc = iw.newDocument();
+    doc.addLargeText("body", "Test a one sentence document.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -232,17 +211,13 @@ public class TestPostingsHighlighter ext
     IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
-    
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Document doc = new Document();
-    
+    FieldTypes fieldTypes = iw.getFieldTypes();
+    fieldTypes.setMultiValued("body");
+
+    Document doc = iw.newDocument();
     for(int i = 0; i < 3 ; i++) {
-      Field body = new Field("body", "", offsetsType);
-      body.setStringValue("This is a multivalued field");
-      doc.add(body);
+      doc.addLargeText("body", "This is a multivalued field");
     }
-    
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -268,19 +243,14 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Field title = new Field("title", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    doc.add(title);
-    
-    body.setStringValue("This is a test. Just a test highlighting from postings. Feel free to ignore.");
-    title.setStringValue("I am hoping for the best.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test. Just a test highlighting from postings. Feel free to ignore.");
+    doc.addLargeText("title", "I am hoping for the best.");
     iw.addDocument(doc);
-    body.setStringValue("Highlighting the first term. Hope it works.");
-    title.setStringValue("But best may not be good enough.");
+
+    doc = iw.newDocument();
+    doc.addLargeText("body", "Highlighting the first term. Hope it works.");
+    doc.addLargeText("title", "But best may not be good enough.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -309,17 +279,14 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test. Just a test highlighting from postings. Feel free to ignore.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test. Just a test highlighting from postings. Feel free to ignore.");
     iw.addDocument(doc);
-    body.setStringValue("Highlighting the first term. Hope it works.");
+
+    doc = iw.newDocument();
+    doc.addLargeText("body", "Highlighting the first term. Hope it works.");
     iw.addDocument(doc);
-    
+
     IndexReader ir = iw.getReader();
     iw.close();
     
@@ -345,16 +312,13 @@ public class TestPostingsHighlighter ext
     IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
-    
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test. Just a test highlighting from postings. Feel free to ignore.");
+
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test. Just a test highlighting from postings. Feel free to ignore.");
     iw.addDocument(doc);
-    body.setStringValue("This test is another test. Not a good sentence. Test test test test.");
+
+    doc = iw.newDocument();
+    doc.addLargeText("body", "This test is another test. Not a good sentence. Test test test test.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -379,20 +343,17 @@ public class TestPostingsHighlighter ext
     IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
-    
-    FieldType positionsType = new FieldType(TextField.TYPE_STORED);
-    positionsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
-    Field body = new Field("body", "", positionsType);
-    Field title = new StringField("title", "", Field.Store.YES);
-    Document doc = new Document();
-    doc.add(body);
-    doc.add(title);
-    
-    body.setStringValue("This is a test. Just a test highlighting from postings. Feel free to ignore.");
-    title.setStringValue("test");
+    FieldTypes fieldTypes = iw.getFieldTypes();
+    fieldTypes.disableHighlighting("body");
+
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test. Just a test highlighting from postings. Feel free to ignore.");
+    doc.addAtom("title", "test");
     iw.addDocument(doc);
-    body.setStringValue("This test is another test. Not a good sentence. Test test test test.");
-    title.setStringValue("test");
+
+    doc = iw.newDocument();
+    doc.addLargeText("body", "This test is another test. Not a good sentence. Test test test test.");
+    doc.addAtom("title", "test");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -434,12 +395,10 @@ public class TestPostingsHighlighter ext
     Analyzer analyzer = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, analyzer);
     
-    FieldType positionsType = new FieldType(TextField.TYPE_STORED);
-    positionsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", text, positionsType);
-    Document document = new Document();
-    document.add(body);
+    Document document = iw.newDocument();
+    document.addLargeText("body", text);
     iw.addDocument(document);
+
     IndexReader ir = iw.getReader();
     iw.close();
     IndexSearcher searcher = newSearcher(ir);
@@ -464,12 +423,11 @@ public class TestPostingsHighlighter ext
     Directory dir = newDirectory();
     Analyzer analyzer = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, analyzer);
-    FieldType positionsType = new FieldType(TextField.TYPE_STORED);
-    positionsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", text, positionsType);
-    Document document = new Document();
-    document.add(body);
+
+    Document document = iw.newDocument();
+    document.addLargeText("body", text);
     iw.addDocument(document);
+
     IndexReader ir = iw.getReader();
     iw.close();
     IndexSearcher searcher = newSearcher(ir);
@@ -494,12 +452,10 @@ public class TestPostingsHighlighter ext
     Directory dir = newDirectory();
     Analyzer analyzer = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, analyzer);
-    FieldType positionsType = new FieldType(TextField.TYPE_STORED);
-    positionsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", text, positionsType);
-    Document document = new Document();
-    document.add(body);
+    Document document = iw.newDocument();
+    document.addLargeText("body", text);
     iw.addDocument(document);
+
     IndexReader ir = iw.getReader();
     iw.close();
     IndexSearcher searcher = newSearcher(ir);
@@ -524,13 +480,8 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test.  Just highlighting from postings. This is also a much sillier test.  Feel free to test test test test test test test.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test.  Just highlighting from postings. This is also a much sillier test.  Feel free to test test test test test test test.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -553,12 +504,9 @@ public class TestPostingsHighlighter ext
     Directory dir = newDirectory();
     Analyzer analyzer = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, analyzer);
-    FieldType positionsType = new FieldType(TextField.TYPE_STORED);
-    positionsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "This sentence has both terms.  This sentence has only terms.", positionsType);
-    Document document = new Document();
-    document.add(body);
-    iw.addDocument(document);
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This sentence has both terms.  This sentence has only terms.");
+    iw.addDocument(doc);
     IndexReader ir = iw.getReader();
     iw.close();
     IndexSearcher searcher = newSearcher(ir);
@@ -583,13 +531,8 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test.  Just highlighting from postings. This is also a much sillier test.  Feel free to test test test test test test test.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test.  Just highlighting from postings. This is also a much sillier test.  Feel free to test test test test test test test.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -619,15 +562,11 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test. Just a test highlighting from postings. Feel free to ignore.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test. Just a test highlighting from postings. Feel free to ignore.");
     iw.addDocument(doc);
-    body.setStringValue("Highlighting the first term. Hope it works.");
+    doc = iw.newDocument();
+    doc.addLargeText("body", "Highlighting the first term. Hope it works.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -657,13 +596,9 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    Document doc = new Document();
-
-    FieldType offsetsType = new FieldType(TextField.TYPE_NOT_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
+    Document doc = iw.newDocument();
     final String text = "This is a test.  Just highlighting from postings. This is also a much sillier test.  Feel free to test test test test test test test.";
-    Field body = new Field("body", text, offsetsType);
-    doc.add(body);
+    doc.addLargeText("body", text);
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -706,12 +641,9 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Document doc = new Document();
+    Document doc = iw.newDocument();
 
-    Field body = new Field("body", "test this is.  another sentence this test has.  far away is that planet.", offsetsType);
-    doc.add(body);
+    doc.addLargeText("body", "test this is.  another sentence this test has.  far away is that planet.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -737,12 +669,8 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Document doc = new Document();
-
-    Field body = new Field("body", "test this is.  another sentence this test has.  far away is that planet.", offsetsType);
-    doc.add(body);
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "test this is.  another sentence this test has.  far away is that planet.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -773,12 +701,8 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Document doc = new Document();
-
-    Field body = new Field("body", "test this is.  another sentence this test has.  far away is that planet.", offsetsType);
-    doc.add(body);
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "test this is.  another sentence this test has.  far away is that planet.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -809,12 +733,8 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Document doc = new Document();
-
-    Field body = new Field("body", "test this is.  another sentence this test has.  far away is that planet.", offsetsType);
-    doc.add(body);
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "test this is.  another sentence this test has.  far away is that planet.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -838,16 +758,13 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-
-    Document doc = new Document();
-    doc.add(new Field("body", "   ", offsetsType));
-    doc.add(new Field("id", "id", offsetsType));
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "   ");
+    doc.addLargeText("id", "id");
     iw.addDocument(doc);
 
-    doc = new Document();
-    doc.add(new Field("body", "something", offsetsType));
+    doc = iw.newDocument();
+    doc.addLargeText("body", "something");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -873,17 +790,14 @@ public class TestPostingsHighlighter ext
     IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
-    
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
 
-    Document doc = new Document();
-    doc.add(new Field("body", "", offsetsType));
-    doc.add(new Field("id", "id", offsetsType));
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "");
+    doc.addLargeText("id", "id");
     iw.addDocument(doc);
 
-    doc = new Document();
-    doc.add(new Field("body", "something", offsetsType));
+    doc = iw.newDocument();
+    doc.addLargeText("body", "something");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -910,18 +824,15 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-
     int numDocs = atLeast(100);
     for(int i=0;i<numDocs;i++) {
-      Document doc = new Document();
+      Document doc = iw.newDocument();
       String content = "the answer is " + i;
       if ((i & 1) == 0) {
         content += " some more terms";
       }
-      doc.add(new Field("body", content, offsetsType));
-      doc.add(newStringField("id", ""+i, Field.Store.YES));
+      doc.addLargeText("body", content);
+      doc.addAtom("id", ""+i);
       iw.addDocument(doc);
 
       if (random().nextInt(10) == 2) {
@@ -941,7 +852,7 @@ public class TestPostingsHighlighter ext
     String snippets[] = highlighter.highlight("body", query, searcher, hits);
     assertEquals(numDocs, snippets.length);
     for(int hit=0;hit<numDocs;hit++) {
-      Document2 doc = searcher.doc(hits.scoreDocs[hit].doc);
+      Document doc = searcher.doc(hits.scoreDocs[hit].doc);
       int id = Integer.parseInt(doc.getString("id"));
       String expected = "the <b>answer</b> is " + id;
       if ((id  & 1) == 0) {
@@ -960,16 +871,9 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Field title = new Field("title", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    doc.add(title);
-    
-    body.setStringValue("This is a test. Just a test highlighting from postings. Feel free to ignore.");
-    title.setStringValue("This is a test. Just a test highlighting from postings. Feel free to ignore.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test. Just a test highlighting from postings. Feel free to ignore.");
+    doc.addLargeText("title", "This is a test. Just a test highlighting from postings. Feel free to ignore.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -995,13 +899,8 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test. Just a test highlighting from <i>postings</i>. Feel free to ignore.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test. Just a test highlighting from <i>postings</i>. Feel free to ignore.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -1032,19 +931,12 @@ public class TestPostingsHighlighter ext
     IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
-    
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Document doc = new Document();
-    
-    Field body1 = new Field("body", "", offsetsType);
-    body1.setStringValue("This is a multivalued field");
-    doc.add(body1);
-    
-    Field body2 = new Field("body", "", offsetsType);
-    body2.setStringValue("This is something different");
-    doc.add(body2);
-    
+    FieldTypes fieldTypes = iw.getFieldTypes();
+    fieldTypes.setMultiValued("body");
+
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a multivalued field");
+    doc.addLargeText("body", "This is something different");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -1076,15 +968,10 @@ public class TestPostingsHighlighter ext
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test. Just a test highlighting from postings. Feel free to ignore.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body", "This is a test. Just a test highlighting from postings. Feel free to ignore.");
     iw.addDocument(doc);
-    
+
     IndexReader ir = iw.getReader();
     iw.close();
     

Modified: lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java (original)
+++ lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java Sun Nov 30 11:07:09 2014
@@ -24,11 +24,6 @@ import java.util.Random;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.MockTokenizer;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.StringField;
-import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.RandomIndexWriter;
@@ -63,13 +58,6 @@ public class TestPostingsHighlighterRank
     
     Directory dir = newDirectory();
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, new MockAnalyzer(random(), MockTokenizer.SIMPLE, true));
-    Document document = new Document();
-    Field id = new StringField("id", "", Field.Store.NO);
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    document.add(id);
-    document.add(body);
     
     for (int i = 0; i < numDocs; i++) {
       StringBuilder bodyText = new StringBuilder();
@@ -77,8 +65,9 @@ public class TestPostingsHighlighterRank
       for (int j = 0; j < numSentences; j++) {
         bodyText.append(newSentence(random(), maxSentenceLength));
       }
-      body.setStringValue(bodyText.toString());
-      id.setStringValue(Integer.toString(i));
+      Document document = iw.newDocument();
+      document.addLargeText("body", bodyText.toString());
+      document.addAtom("id", Integer.toString(i));
       iw.addDocument(document);
     }
     
@@ -251,14 +240,10 @@ public class TestPostingsHighlighterRank
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This is a test.  This test is a better test but the sentence is excruiatingly long, " + 
-                        "you have no idea how painful it was for me to type this long sentence into my IDE.");
+    Document doc = iw.newDocument();
+    doc.addLargeText("body",
+                    "This is a test.  This test is a better test but the sentence is excruiatingly long, " + 
+                    "you have no idea how painful it was for me to type this long sentence into my IDE.");
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
@@ -289,13 +274,9 @@ public class TestPostingsHighlighterRank
     iwc.setMergePolicy(newLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     
-    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
-    offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
-    Field body = new Field("body", "", offsetsType);
-    Document doc = new Document();
-    doc.add(body);
-    
-    body.setStringValue("This has only foo foo. " + 
+    Document doc = iw.newDocument();
+    doc.addLargeText("body",
+                     "This has only foo foo. " + 
                         "On the other hand this sentence contains both foo and bar. " + 
                         "This has only bar bar bar bar bar bar bar bar bar bar bar bar.");
     iw.addDocument(doc);

Modified: lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java Sun Nov 30 11:07:09 2014
@@ -26,12 +26,8 @@ import org.apache.lucene.analysis.*;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
 import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
-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.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
@@ -357,7 +353,7 @@ public abstract class AbstractTestCase e
     fieldTypes.enableTermVectorPositions(F);
     fieldTypes.setMultiValued(F);
 
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
 
     for( String value: values ) {
       doc.addLargeText(F, value);
@@ -376,7 +372,7 @@ public abstract class AbstractTestCase e
     fieldTypes.enableTermVectorOffsets(F);
     fieldTypes.enableTermVectorPositions(F);
     fieldTypes.setMultiValued(F);
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
     for( String value: values ) {
       doc.addLargeText(F, value);
       //doc.add( new Field( F, value, Store.YES, Index.NOT_ANALYZED, TermVector.WITH_POSITIONS_OFFSETS ) );

Modified: lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java (original)
+++ lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java Sun Nov 30 11:07:09 2014
@@ -28,13 +28,8 @@ import org.apache.lucene.analysis.MockAn
 import org.apache.lucene.analysis.MockTokenFilter;
 import org.apache.lucene.analysis.MockTokenizer;
 import org.apache.lucene.analysis.Token;
-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.TextField;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
@@ -66,7 +61,7 @@ public class FastVectorHighlighterTest e
     fieldTypes.enableTermVectors("field");
     fieldTypes.enableTermVectorPositions("field");
     fieldTypes.enableTermVectorOffsets("field");
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
     doc.addLargeText("field", "This is a test where foo is highlighed and should be highlighted");
     writer.addDocument(doc);
     FastVectorHighlighter highlighter = new FastVectorHighlighter();
@@ -93,7 +88,7 @@ public class FastVectorHighlighterTest e
     fieldTypes.enableTermVectors("text");
     fieldTypes.enableTermVectorPositions("text");
     fieldTypes.enableTermVectorOffsets("text");
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
     doc.addLargeText("text", 
         "Netscape was the general name for a series of web browsers originally produced by Netscape Communications Corporation, now a subsidiary of AOL The original browser was once the dominant browser in terms of usage share, but as a result of the first browser war it lost virtually all of its share to Internet Explorer Netscape was discontinued and support for all Netscape browsers and client products was terminated on March 1, 2008 Netscape Navigator was the name of Netscape\u0027s web browser from versions 1.0 through 4.8 The first beta release versions of the browser were released in 1994 and known as Mosaic and then Mosaic Netscape until a legal challenge from the National Center for Supercomputing Applications (makers of NCSA Mosaic, which many of Netscape\u0027s founders used to develop), led to the name change to Netscape Navigator The company\u0027s name also changed from Mosaic Communications Corporation to Netscape Communications Corporation The browser was easily the 
 most advanced...");
     writer.addDocument(doc);
@@ -139,7 +134,7 @@ public class FastVectorHighlighterTest e
       fieldTypes.enableTermVectorPositions(fieldName);
       fieldTypes.enableTermVectorOffsets(fieldName);
     }
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
     doc.addLargeText("long_term", "This is a test thisisaverylongwordandmakessurethisfails where foo is highlighed and should be highlighted");
     doc.addLargeText("no_long_term", "This is a test where foo is highlighed and should be highlighted");
     writer.addDocument(doc);
@@ -264,7 +259,7 @@ public class FastVectorHighlighterTest e
       fieldTypes.enableTermVectorPositions(fieldName);
       fieldTypes.enableTermVectorOffsets(fieldName);
     }
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
     StringBuilder text = new StringBuilder();
     text.append("words words junk junk junk junk junk junk junk junk highlight junk junk junk junk together junk ");
     for ( int i = 0; i<10; i++ ) {
@@ -317,7 +312,7 @@ public class FastVectorHighlighterTest e
         "This text has a typo in referring to Keneddy",
         "wordx wordy wordz wordx wordy wordx worda wordb wordy wordc", "y z x y z a b", "lets is a the lets is a the lets is a the lets" };
     for (int i = 0; i < texts.length; i++) {
-      Document2 doc = writer.newDocument();
+      Document doc = writer.newDocument();
       doc.addLargeText("field", texts[i]);
       writer.addDocument(doc);
     }
@@ -465,7 +460,7 @@ public class FastVectorHighlighterTest e
       fieldTypes.enableTermVectorOffsets(fieldName);
       fieldTypes.setMultiValued(fieldName);
     }
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
     doc.addLargeText( "field", "zero if naught"); // The first two fields contain the best match
     doc.addLargeText( "field", "hero of legend" ); // but total a lower score (3) than the bottom
     doc.addLargeText( "field", "naught of hero" ); // two fields (4)
@@ -515,7 +510,7 @@ public class FastVectorHighlighterTest e
       fieldTypes.enableTermVectorPositions(fieldName);
       fieldTypes.enableTermVectorOffsets(fieldName);
     }
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
     Token syn = new Token("httpwwwfacebookcom", 6, 29);
     syn.setPositionIncrement(0);
     CannedTokenStream ts = new CannedTokenStream(
@@ -601,7 +596,7 @@ public class FastVectorHighlighterTest e
         fieldTypes.disableStored(fieldName);
       }
     }
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
     doc.addLargeText( "field", fieldValue );               // Whitespace tokenized with English stop words
     doc.addLargeText( "field_exact", fieldValue );        // Whitespace tokenized without stop words
     doc.addLargeText( "field_super_exact", fieldValue );  // Whitespace tokenized without toLower

Modified: lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java (original)
+++ lucene/dev/branches/lucene6005/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java Sun Nov 30 11:07:09 2014
@@ -25,12 +25,8 @@ 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.FieldType;
 import org.apache.lucene.document.FieldTypes;
-import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
@@ -156,7 +152,7 @@ public class SimpleFragmentsBuilderTest 
     fieldTypes.enableTermVectorOffsets(F);
     fieldTypes.enableTermVectorPositions(F);
     fieldTypes.disableStored(F);
-    Document2 doc = writer.newDocument();
+    Document doc = writer.newDocument();
     doc.addLargeText(F, "aaa");
     writer.addDocument( doc );
     writer.close();
@@ -250,10 +246,10 @@ public class SimpleFragmentsBuilderTest 
     int numFields = 2 + random().nextInt(5);
     int numTerms = 2 + random().nextInt(3);
     List<Doc> docs = new ArrayList<>(numDocs);
-    List<Document2> documents = new ArrayList<>(numDocs);
+    List<Document> documents = new ArrayList<>(numDocs);
     Map<String, Set<Integer>> valueToDocId = new HashMap<>();
     for (int i = 0; i < numDocs; i++) {
-      Document2 document = writer.newDocument();
+      Document document = writer.newDocument();
       String[][] fields = new String[numFields][numTerms];
       for (int j = 0; j < numFields; j++) {
         String[] fieldValues = new String[numTerms];

Modified: lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java (original)
+++ lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java Sun Nov 30 11:07:09 2014
@@ -37,8 +37,8 @@ import org.apache.lucene.util.*;
 public class TestBlockJoin extends LuceneTestCase {
 
   // One resume...
-  private Document2 makeResume(IndexWriter w, String name, String country) {
-    Document2 resume = w.newDocument();
+  private Document makeResume(IndexWriter w, String name, String country) {
+    Document resume = w.newDocument();
     resume.addAtom("docType", "resume");
     resume.addAtom("name", name);
     resume.addAtom("country", country);
@@ -46,16 +46,16 @@ public class TestBlockJoin extends Lucen
   }
 
   // ... has multiple jobs
-  private Document2 makeJob(IndexWriter w, String skill, int year) {
-    Document2 job = w.newDocument();
+  private Document makeJob(IndexWriter w, String skill, int year) {
+    Document job = w.newDocument();
     job.addAtom("skill", skill);
     job.addInt("year", year);
     return job;
   }
 
   // ... has multiple qualifications
-  private Document2 makeQualification(IndexWriter w, String qualification, int year) {
-    Document2 job = w.newDocument();
+  private Document makeQualification(IndexWriter w, String qualification, int year) {
+    Document job = w.newDocument();
     job.addAtom("qualification", qualification);
     job.addInt("year", year);
     return job;
@@ -68,7 +68,7 @@ public class TestBlockJoin extends Lucen
     // we don't want to merge - since we rely on certain segment setup
     final IndexWriter w = new IndexWriter(dir, config);
 
-    final List<Document2> docs = new ArrayList<>();
+    final List<Document> docs = new ArrayList<>();
 
     docs.add(makeJob(w, "java", 2007));
     docs.add(makeJob(w, "python", 2010));
@@ -112,10 +112,10 @@ public class TestBlockJoin extends Lucen
     assertEquals(1, results.totalGroupedHitCount);
     assertEquals(1, results.groups.length);
     final GroupDocs<Integer> group = results.groups[0];
-    Document2 childDoc = s.doc(group.scoreDocs[0].doc);
+    Document childDoc = s.doc(group.scoreDocs[0].doc);
     assertEquals("java", childDoc.getString("skill"));
     assertNotNull(group.groupValue);
-    Document2 parentDoc = s.doc(group.groupValue);
+    Document parentDoc = s.doc(group.groupValue);
     assertEquals("Lisa", parentDoc.getString("name"));
 
     r.close();
@@ -128,7 +128,7 @@ public class TestBlockJoin extends Lucen
     final Directory dir = newDirectory();
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
 
-    final List<Document2> docs = new ArrayList<>();
+    final List<Document> docs = new ArrayList<>();
 
     docs.add(makeJob(w.w, "java", 2007));
     docs.add(makeJob(w.w, "python", 2010));
@@ -181,11 +181,11 @@ public class TestBlockJoin extends Lucen
     assertEquals(1, group.totalHits);
     assertFalse(Float.isNaN(group.score));
 
-    Document2 childDoc = s.doc(group.scoreDocs[0].doc);
+    Document childDoc = s.doc(group.scoreDocs[0].doc);
     //System.out.println("  doc=" + group.scoreDocs[0].doc);
     assertEquals("java", childDoc.getString("skill"));
     assertNotNull(group.groupValue);
-    Document2 parentDoc = s.doc(group.groupValue);
+    Document parentDoc = s.doc(group.groupValue);
     assertEquals("Lisa", parentDoc.get("name"));
 
 
@@ -219,7 +219,7 @@ public class TestBlockJoin extends Lucen
     final Directory dir = newDirectory();
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
 
-    final List<Document2> docs = new ArrayList<>();
+    final List<Document> docs = new ArrayList<>();
 
     for (int i=0;i<10;i++) {
       docs.clear();
@@ -234,7 +234,7 @@ public class TestBlockJoin extends Lucen
     IndexSearcher s = newSearcher(r);
     FieldTypes fieldTypes = s.getFieldTypes();
 
-    MultiTermQuery qc = new TermRangeQuery("year", Document2.intToBytes(2007), Document2.intToBytes(2007), true, true);
+    MultiTermQuery qc = new TermRangeQuery("year", Document.intToBytes(2007), Document.intToBytes(2007), true, true);
     // Hacky: this causes the query to need 2 rewrite
     // iterations: 
     qc.setRewriteMethod(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE);
@@ -273,13 +273,13 @@ public class TestBlockJoin extends Lucen
     final Directory dir = newDirectory();
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
 
-    final List<Document2> docs = new ArrayList<>();
+    final List<Document> docs = new ArrayList<>();
     docs.add(makeJob(w.w, "java", 2007));
     docs.add(makeJob(w.w, "python", 2010));
     Collections.shuffle(docs, random());
     docs.add(makeResume(w.w, "Lisa", "United Kingdom"));
 
-    final List<Document2> docs2 = new ArrayList<>();
+    final List<Document> docs2 = new ArrayList<>();
     docs2.add(makeJob(w.w, "ruby", 2005));
     docs2.add(makeJob(w.w, "java", 2006));
     Collections.shuffle(docs2, random());
@@ -359,7 +359,7 @@ public class TestBlockJoin extends Lucen
     }
   }
   
-  private Document2 getParentDoc(IndexReader reader, BitDocIdSetFilter parents, int childDocID) throws IOException {
+  private Document getParentDoc(IndexReader reader, BitDocIdSetFilter parents, int childDocID) throws IOException {
     final List<LeafReaderContext> leaves = reader.leaves();
     final int subIndex = ReaderUtil.subIndex(childDocID, leaves);
     final LeafReaderContext leaf = leaves.get(subIndex);
@@ -395,7 +395,7 @@ public class TestBlockJoin extends Lucen
     // Cannot assert this since we use NoMergePolicy:
     w.setDoRandomForceMergeAssert(false);
 
-    List<Document2> docs = new ArrayList<>();
+    List<Document> docs = new ArrayList<>();
     docs.add(makeJob(w.w, "java", 2007));
     docs.add(makeJob(w.w, "python", 2010));
     docs.add(makeResume(w.w, "Lisa", "United Kingdom"));
@@ -509,8 +509,8 @@ public class TestBlockJoin extends Lucen
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
     final RandomIndexWriter joinW = new RandomIndexWriter(random(), joinDir);
     for(int parentDocID=0;parentDocID<numParentDocs;parentDocID++) {
-      Document2 parentDoc = w.newDocument();
-      Document2 parentJoinDoc = joinW.newDocument();
+      Document parentDoc = w.newDocument();
+      Document parentJoinDoc = joinW.newDocument();
       parentDoc.addInt("parentID", parentDocID);
       parentJoinDoc.addInt("parentID", parentDocID);
       parentJoinDoc.addAtom("isParent", "x");
@@ -539,7 +539,7 @@ public class TestBlockJoin extends Lucen
         parentJoinDoc.addInt("blockID", parentDocID);
       }
 
-      final List<Document2> joinDocs = new ArrayList<>();
+      final List<Document> joinDocs = new ArrayList<>();
 
       if (VERBOSE) {
         StringBuilder sb = new StringBuilder();
@@ -556,7 +556,7 @@ public class TestBlockJoin extends Lucen
       final int numChildDocs = TestUtil.nextInt(random(), 1, 20);
       for(int childDocID=0;childDocID<numChildDocs;childDocID++) {
         // Denormalize: copy all parent fields into child doc:
-        Document2 childDoc = w.newDocument();
+        Document childDoc = w.newDocument();
         childDoc.addInt("parentID", parentDocID);
         for(int i=0;i<randomFields.length;i++) {
           String s = randomFields[i];
@@ -568,7 +568,7 @@ public class TestBlockJoin extends Lucen
           childDoc.addInt("blockID", parentDocID);
         }
 
-        Document2 joinChildDoc = joinW.newDocument();
+        Document joinChildDoc = joinW.newDocument();
         joinDocs.add(joinChildDoc);
 
         childDoc.addInt("childID", childDocID);
@@ -761,7 +761,7 @@ public class TestBlockJoin extends Lucen
         System.out.println("\nTEST: normal index gets " + results.totalHits + " hits; sort=" + parentAndChildSort);
         final ScoreDoc[] hits = results.scoreDocs;
         for(int hitIDX=0;hitIDX<hits.length;hitIDX++) {
-          final Document2 doc = s.doc(hits[hitIDX].doc);
+          final Document doc = s.doc(hits[hitIDX].doc);
           //System.out.println("  score=" + hits[hitIDX].score + " parentID=" + doc.get("parentID") + " childID=" + doc.get("childID") + " (docID=" + hits[hitIDX].doc + ")");
           System.out.println("  parentID=" + doc.get("parentID") + " childID=" + doc.get("childID") + " (docID=" + hits[hitIDX].doc + ")");
           FieldDoc fd = (FieldDoc) hits[hitIDX];
@@ -815,10 +815,10 @@ public class TestBlockJoin extends Lucen
             }
 
             assertNotNull(group.groupValue);
-            final Document2 parentDoc = joinS.doc(group.groupValue);
+            final Document parentDoc = joinS.doc(group.groupValue);
             System.out.println("  group parentID=" + parentDoc.get("parentID") + " (docID=" + group.groupValue + ")");
             for(int hitIDX=0;hitIDX<group.scoreDocs.length;hitIDX++) {
-              final Document2 doc = joinS.doc(group.scoreDocs[hitIDX].doc);
+              final Document doc = joinS.doc(group.scoreDocs[hitIDX].doc);
               //System.out.println("    score=" + group.scoreDocs[hitIDX].score + " childID=" + doc.get("childID") + " (docID=" + group.scoreDocs[hitIDX].doc + ")");
               System.out.println("    childID=" + doc.getString("childID") + " child0=" + doc.getString("child0") + " (docID=" + group.scoreDocs[hitIDX].doc + ")");
             }
@@ -833,7 +833,7 @@ public class TestBlockJoin extends Lucen
         TopDocs b = joinS.search(childJoinQuery, 10);
         for (ScoreDoc hit : b.scoreDocs) {
           Explanation explanation = joinS.explain(childJoinQuery, hit.doc);
-          Document2 document = joinS.doc(hit.doc - 1);
+          Document document = joinS.doc(hit.doc - 1);
           int childId = document.getInt("childID");
           //System.out.println("  hit docID=" + hit.doc + " childId=" + childId + " parentId=" + document.get("parentID"));
           assertTrue(explanation.isMatch());
@@ -962,7 +962,7 @@ public class TestBlockJoin extends Lucen
       if (VERBOSE) {
         System.out.println("  " + results2.totalHits + " totalHits:");
         for(ScoreDoc sd : results2.scoreDocs) {
-          final Document2 doc = s.doc(sd.doc);
+          final Document doc = s.doc(sd.doc);
           System.out.println("  childID=" + doc.getString("childID") + " parentID=" + doc.get("parentID") + " docID=" + sd.doc);
         }
       }
@@ -976,8 +976,8 @@ public class TestBlockJoin extends Lucen
       if (VERBOSE) {
         System.out.println("  " + joinResults2.totalHits + " totalHits:");
         for(ScoreDoc sd : joinResults2.scoreDocs) {
-          final Document2 doc = joinS.doc(sd.doc);
-          final Document2 parentDoc = getParentDoc(joinR, parentsFilter, sd.doc);
+          final Document doc = joinS.doc(sd.doc);
+          final Document parentDoc = getParentDoc(joinR, parentsFilter, sd.doc);
           System.out.println("  childID=" + doc.getString("childID") + " parentID=" + parentDoc.getString("parentID") + " docID=" + sd.doc);
         }
       }
@@ -997,8 +997,8 @@ public class TestBlockJoin extends Lucen
     for(int hitCount=0;hitCount<results.scoreDocs.length;hitCount++) {
       ScoreDoc hit = results.scoreDocs[hitCount];
       ScoreDoc joinHit = joinResults.scoreDocs[hitCount];
-      Document2 doc1 = r.document(hit.doc);
-      Document2 doc2 = joinR.document(joinHit.doc);
+      Document doc1 = r.document(hit.doc);
+      Document doc2 = joinR.document(joinHit.doc);
       assertEquals("hit " + hitCount + " differs",
                    doc1.getInt("childID"), doc2.getInt("childID"));
       // don't compare scores -- they are expected to differ
@@ -1025,14 +1025,14 @@ public class TestBlockJoin extends Lucen
       final GroupDocs<Integer> group = groupDocs[joinGroupUpto++];
       final ScoreDoc[] groupHits = group.scoreDocs;
       assertNotNull(group.groupValue);
-      final Document2 parentDoc = joinR.document(group.groupValue);
+      final Document parentDoc = joinR.document(group.groupValue);
       final String parentID = Integer.toString(parentDoc.getInt("parentID"));
       //System.out.println("GROUP groupDoc=" + group.groupDoc + " parent=" + parentDoc);
       assertNotNull(parentID);
       assertTrue(groupHits.length > 0);
       for(int hitIDX=0;hitIDX<groupHits.length;hitIDX++) {
-        final Document2 nonJoinHit = r.document(hits[resultUpto++].doc);
-        final Document2 joinHit = joinR.document(groupHits[hitIDX].doc);
+        final Document nonJoinHit = r.document(hits[resultUpto++].doc);
+        final Document joinHit = joinR.document(groupHits[hitIDX].doc);
         assertEquals(parentID,
                      Integer.toString(nonJoinHit.getInt("parentID")));
         assertEquals(joinHit.getInt("childID"),
@@ -1058,7 +1058,7 @@ public class TestBlockJoin extends Lucen
     final Directory dir = newDirectory();
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
 
-    final List<Document2> docs = new ArrayList<>();
+    final List<Document> docs = new ArrayList<>();
 
     docs.add(makeJob(w.w, "java", 2007));
     docs.add(makeJob(w.w, "python", 2010));
@@ -1114,11 +1114,11 @@ public class TestBlockJoin extends Lucen
     final GroupDocs<Integer> group = jobResults.groups[0];
     assertEquals(1, group.totalHits);
 
-    Document2 childJobDoc = s.doc(group.scoreDocs[0].doc);
+    Document childJobDoc = s.doc(group.scoreDocs[0].doc);
     //System.out.println("  doc=" + group.scoreDocs[0].doc);
     assertEquals("java", childJobDoc.getString("skill"));
     assertNotNull(group.groupValue);
-    Document2 parentDoc = s.doc(group.groupValue);
+    Document parentDoc = s.doc(group.groupValue);
     assertEquals("Lisa", parentDoc.getString("name"));
 
     // Now Examine qualification children
@@ -1130,7 +1130,7 @@ public class TestBlockJoin extends Lucen
     final GroupDocs<Integer> qGroup = qualificationResults.groups[0];
     assertEquals(1, qGroup.totalHits);
 
-    Document2 childQualificationDoc = s.doc(qGroup.scoreDocs[0].doc);
+    Document childQualificationDoc = s.doc(qGroup.scoreDocs[0].doc);
     assertEquals("maths", childQualificationDoc.getString("qualification"));
     assertNotNull(qGroup.groupValue);
     parentDoc = s.doc(qGroup.groupValue);
@@ -1143,10 +1143,10 @@ public class TestBlockJoin extends Lucen
   public void testAdvanceSingleParentSingleChild() throws Exception {
     Directory dir = newDirectory();
     RandomIndexWriter w = new RandomIndexWriter(random(), dir);
-    Document childDoc = new Document();
-    childDoc.add(newStringField("child", "1", Field.Store.NO));
-    Document parentDoc = new Document();
-    parentDoc.add(newStringField("parent", "1", Field.Store.NO));
+    Document childDoc = w.newDocument();
+    childDoc.addAtom("child", "1");
+    Document parentDoc = w.newDocument();
+    parentDoc.addAtom("parent", "1");
     w.addDocuments(Arrays.asList(childDoc, parentDoc));
     IndexReader r = w.getReader();
     w.close();
@@ -1167,17 +1167,17 @@ public class TestBlockJoin extends Lucen
   public void testAdvanceSingleParentNoChild() throws Exception {
     Directory dir = newDirectory();
     RandomIndexWriter w = new RandomIndexWriter(random(), dir, newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(new LogDocMergePolicy()));
-    Document parentDoc = new Document();
-    parentDoc.add(newStringField("parent", "1", Field.Store.NO));
-    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
+    Document parentDoc = w.newDocument();
+    parentDoc.addAtom("parent", "1");
+    parentDoc.addAtom("isparent", "yes");
     w.addDocuments(Arrays.asList(parentDoc));
 
     // Add another doc so scorer is not null
-    parentDoc = new Document();
-    parentDoc.add(newStringField("parent", "2", Field.Store.NO));
-    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
-    Document childDoc = new Document();
-    childDoc.add(newStringField("child", "2", Field.Store.NO));
+    parentDoc = w.newDocument();
+    parentDoc.addAtom("parent", "2");
+    parentDoc.addAtom("isparent", "yes");
+    Document childDoc = w.newDocument();
+    childDoc.addAtom("child", "2");
     w.addDocuments(Arrays.asList(childDoc, parentDoc));
 
     // Need single seg:
@@ -1203,7 +1203,7 @@ public class TestBlockJoin extends Lucen
     final Directory dir = newDirectory();
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
 
-    final List<Document2> docs = new ArrayList<>();
+    final List<Document> docs = new ArrayList<>();
     docs.add(makeJob(w.w, "ruby", 2005));
     docs.add(makeJob(w.w, "java", 2006));
     docs.add(makeJob(w.w, "java", 2010));
@@ -1250,13 +1250,13 @@ public class TestBlockJoin extends Lucen
       assertEquals(2, group.totalHits);
       assertFalse(Float.isNaN(group.score));
       assertNotNull(group.groupValue);
-      Document2 parentDoc = s.doc(group.groupValue);
+      Document parentDoc = s.doc(group.groupValue);
       assertEquals("Frank", parentDoc.getString("name"));
 
       assertEquals(2, group.scoreDocs.length); //all matched child documents collected
 
       for (ScoreDoc scoreDoc : group.scoreDocs) {
-        Document2 childDoc = s.doc(scoreDoc.doc);
+        Document childDoc = s.doc(scoreDoc.doc);
         assertEquals("java", childDoc.getString("skill"));
         int year = childDoc.getInt("year");
         assertTrue(year >= 2006 && year <= 2011);
@@ -1273,13 +1273,13 @@ public class TestBlockJoin extends Lucen
     assertEquals(2, group.totalHits);
     assertFalse(Float.isNaN(group.score));
     assertNotNull(group.groupValue);
-    Document2 parentDoc = s.doc(group.groupValue);
+    Document parentDoc = s.doc(group.groupValue);
     assertEquals("Frank", parentDoc.getString("name"));
 
     assertEquals(1, group.scoreDocs.length); //not all matched child documents collected
 
     for (ScoreDoc scoreDoc : group.scoreDocs) {
-      Document2 childDoc = s.doc(scoreDoc.doc);
+      Document childDoc = s.doc(scoreDoc.doc);
       assertEquals("java", childDoc.getString("skill"));
       int year = childDoc.getInt("year");
       assertTrue(year >= 2006 && year <= 2011);
@@ -1293,18 +1293,17 @@ public class TestBlockJoin extends Lucen
   public void testSometimesParentOnlyMatches() throws Exception {
     Directory d = newDirectory();
     RandomIndexWriter w = new RandomIndexWriter(random(), d);
-    Document parent = new Document();
-    parent.add(new StoredField("parentID", "0"));
-    parent.add(new SortedDocValuesField("parentID", new BytesRef("0")));
-    parent.add(newTextField("parentText", "text", Field.Store.NO));
-    parent.add(newStringField("isParent", "yes", Field.Store.NO));
+    Document parent = w.newDocument();
+    parent.addAtom("parentID", "0");
+    parent.addLargeText("parentText", "text");
+    parent.addAtom("isParent", "yes");
 
     List<Document> docs = new ArrayList<>();
 
-    Document child = new Document();
+    Document child = w.newDocument();
     docs.add(child);
-    child.add(new StoredField("childID", "0"));
-    child.add(newTextField("childText", "text", Field.Store.NO));
+    child.addStored("childID", "0");
+    child.addLargeText("childText", "text");
 
     // parent last:
     docs.add(parent);
@@ -1312,11 +1311,10 @@ public class TestBlockJoin extends Lucen
 
     docs.clear();
 
-    parent = new Document();
-    parent.add(newTextField("parentText", "text", Field.Store.NO));
-    parent.add(newStringField("isParent", "yes", Field.Store.NO));
-    parent.add(new StoredField("parentID", "1"));
-    parent.add(new SortedDocValuesField("parentID", new BytesRef("1")));
+    parent = w.newDocument();
+    parent.addLargeText("parentText", "text");
+    parent.addAtom("isParent", "yes");
+    parent.addAtom("parentID", "1");
 
     // parent last:
     docs.add(parent);
@@ -1344,7 +1342,7 @@ public class TestBlockJoin extends Lucen
     assertEquals(1, groups.totalGroupedHitCount);
 
     GroupDocs<Integer> group = groups.groups[0];
-    Document2 doc = r.document(group.groupValue.intValue());
+    Document doc = r.document(group.groupValue.intValue());
     assertEquals("0", doc.getString("parentID"));
 
     group = groups.groups[1];
@@ -1359,18 +1357,17 @@ public class TestBlockJoin extends Lucen
   public void testChildQueryNeverMatches() throws Exception {
     Directory d = newDirectory();
     RandomIndexWriter w = new RandomIndexWriter(random(), d);
-    Document parent = new Document();
-    parent.add(new StoredField("parentID", "0"));
-    parent.add(new SortedDocValuesField("parentID", new BytesRef("0")));
-    parent.add(newTextField("parentText", "text", Field.Store.NO));
-    parent.add(newStringField("isParent", "yes", Field.Store.NO));
+    Document parent = w.newDocument();
+    parent.addAtom("parentID", "0");
+    parent.addLargeText("parentText", "text");
+    parent.addAtom("isParent", "yes");
 
     List<Document> docs = new ArrayList<>();
 
-    Document child = new Document();
+    Document child = w.newDocument();
     docs.add(child);
-    child.add(new StoredField("childID", "0"));
-    child.add(newTextField("childText", "text", Field.Store.NO));
+    child.addStored("childID", "0");
+    child.addLargeText("childText", "text");
 
     // parent last:
     docs.add(parent);
@@ -1378,11 +1375,10 @@ public class TestBlockJoin extends Lucen
 
     docs.clear();
 
-    parent = new Document();
-    parent.add(newTextField("parentText", "text", Field.Store.NO));
-    parent.add(newStringField("isParent", "yes", Field.Store.NO));
-    parent.add(new StoredField("parentID", "1"));
-    parent.add(new SortedDocValuesField("parentID", new BytesRef("1")));
+    parent = w.newDocument();
+    parent.addLargeText("parentText", "text");
+    parent.addAtom("isParent", "yes");
+    parent.addAtom("parentID", "1");
     
 
     // parent last:
@@ -1412,7 +1408,7 @@ public class TestBlockJoin extends Lucen
     assertEquals(0, groups.totalGroupedHitCount);
 
     GroupDocs<Integer> group = groups.groups[0];
-    Document2 doc = r.document(group.groupValue.intValue());
+    Document doc = r.document(group.groupValue.intValue());
     assertEquals("0", doc.getString("parentID"));
 
     group = groups.groups[1];
@@ -1427,17 +1423,17 @@ public class TestBlockJoin extends Lucen
   public void testChildQueryMatchesParent() throws Exception {
     Directory d = newDirectory();
     RandomIndexWriter w = new RandomIndexWriter(random(), d);
-    Document parent = new Document();
-    parent.add(new StoredField("parentID", "0"));
-    parent.add(newTextField("parentText", "text", Field.Store.NO));
-    parent.add(newStringField("isParent", "yes", Field.Store.NO));
+    Document parent = w.newDocument();
+    parent.addStored("parentID", "0");
+    parent.addLargeText("parentText", "text");
+    parent.addAtom("isParent", "yes");
 
     List<Document> docs = new ArrayList<>();
 
-    Document child = new Document();
+    Document child = w.newDocument();
     docs.add(child);
-    child.add(new StoredField("childID", "0"));
-    child.add(newTextField("childText", "text", Field.Store.NO));
+    child.addStored("childID", "0");
+    child.addLargeText("childText", "text");
 
     // parent last:
     docs.add(parent);
@@ -1445,10 +1441,10 @@ public class TestBlockJoin extends Lucen
 
     docs.clear();
 
-    parent = new Document();
-    parent.add(newTextField("parentText", "text", Field.Store.NO));
-    parent.add(newStringField("isParent", "yes", Field.Store.NO));
-    parent.add(new StoredField("parentID", "1"));
+    parent = w.newDocument();
+    parent.addLargeText("parentText", "text");
+    parent.addAtom("isParent", "yes");
+    parent.addStored("parentID", "1");
 
     // parent last:
     docs.add(parent);
@@ -1485,25 +1481,25 @@ public class TestBlockJoin extends Lucen
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
 
     // First doc with 1 children
-    Document parentDoc = new Document();
-    parentDoc.add(newStringField("parent", "1", Field.Store.NO));
-    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
-    Document childDoc = new Document();
-    childDoc.add(newStringField("child", "1", Field.Store.NO));
+    Document parentDoc = w.newDocument();
+    parentDoc.addAtom("parent", "1");
+    parentDoc.addAtom("isparent", "yes");
+    Document childDoc = w.newDocument();
+    childDoc.addAtom("child", "1");
     w.addDocuments(Arrays.asList(childDoc, parentDoc));
 
-    parentDoc = new Document();
-    parentDoc.add(newStringField("parent", "2", Field.Store.NO));
-    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
+    parentDoc = w.newDocument();
+    parentDoc.addAtom("parent", "2");
+    parentDoc.addAtom("isparent", "yes");
     w.addDocuments(Arrays.asList(parentDoc));
 
     w.deleteDocuments(new Term("parent", "2"));
 
-    parentDoc = new Document();
-    parentDoc.add(newStringField("parent", "2", Field.Store.NO));
-    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
-    childDoc = new Document();
-    childDoc.add(newStringField("child", "2", Field.Store.NO));
+    parentDoc = w.newDocument();
+    parentDoc.addAtom("parent", "2");
+    parentDoc.addAtom("isparent", "yes");
+    childDoc = w.newDocument();
+    childDoc.addAtom("child", "2");
     w.addDocuments(Arrays.asList(childDoc, parentDoc));
 
     IndexReader r = w.getReader();

Modified: lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java (original)
+++ lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java Sun Nov 30 11:07:09 2014
@@ -17,17 +17,16 @@ package org.apache.lucene.search.join;
  * limitations under the License.
  */
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.SortedDocValuesField;
-import org.apache.lucene.document.StringField;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.NoMergePolicy;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.FieldDoc;
-import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.FilteredQuery;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.MatchAllDocsQuery;
@@ -42,9 +41,6 @@ import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
 import org.junit.Test;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  */
 public class TestBlockJoinSorting extends LuceneTestCase {
@@ -56,177 +52,156 @@ public class TestBlockJoinSorting extend
         .setMergePolicy(NoMergePolicy.INSTANCE));
 
     List<Document> docs = new ArrayList<>();
-    Document document = new Document();
-    document.add(new StringField("field2", "a", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("a")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "b", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("b")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "c", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("c")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("__type", "parent", Field.Store.NO));
-    document.add(new StringField("field1", "a", Field.Store.NO));
+    Document document = w.newDocument();
+    document.addAtom("field2", "a");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "b");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "c");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("__type", "parent");
+    document.addAtom("field1", "a");
     docs.add(document);
     w.addDocuments(docs);
     w.commit();
 
     docs.clear();
-    document = new Document();
-    document.add(new StringField("field2", "c", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("c")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "d", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("d")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "e", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("e")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("__type", "parent", Field.Store.NO));
-    document.add(new StringField("field1", "b", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("field2", "c");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "d");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "e");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("__type", "parent");
+    document.addAtom("field1", "b");
     docs.add(document);
     w.addDocuments(docs);
 
     docs.clear();
-    document = new Document();
-    document.add(new StringField("field2", "e", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("e")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "f", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("f")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "g", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("g")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("__type", "parent", Field.Store.NO));
-    document.add(new StringField("field1", "c", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("field2", "e");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "f");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "g");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("__type", "parent");
+    document.addAtom("field1", "c");
     docs.add(document);
     w.addDocuments(docs);
 
     docs.clear();
-    document = new Document();
-    document.add(new StringField("field2", "g", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("g")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "h", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("h")));
-    document.add(new StringField("filter_1", "F", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "i", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("i")));
-    document.add(new StringField("filter_1", "F", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("__type", "parent", Field.Store.NO));
-    document.add(new StringField("field1", "d", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("field2", "g");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "h");
+    document.addAtom("filter_1", "F");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "i");
+    document.addAtom("filter_1", "F");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("__type", "parent");
+    document.addAtom("field1", "d");
     docs.add(document);
     w.addDocuments(docs);
     w.commit();
 
     docs.clear();
-    document = new Document();
-    document.add(new StringField("field2", "i", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("i")));
-    document.add(new StringField("filter_1", "F", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "j", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("j")));
-    document.add(new StringField("filter_1", "F", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "k", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("k")));
-    document.add(new StringField("filter_1", "F", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("__type", "parent", Field.Store.NO));
-    document.add(new StringField("field1", "f", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("field2", "i");
+    document.addAtom("filter_1", "F");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "j");
+    document.addAtom("filter_1", "F");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "k");
+    document.addAtom("filter_1", "F");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("__type", "parent");
+    document.addAtom("field1", "f");
     docs.add(document);
     w.addDocuments(docs);
 
     docs.clear();
-    document = new Document();
-    document.add(new StringField("field2", "k", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("k")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "l", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("l")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "m", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("m")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("__type", "parent", Field.Store.NO));
-    document.add(new StringField("field1", "g", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("field2", "k");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "l");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "m");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("__type", "parent");
+    document.addAtom("field1", "g");
     docs.add(document);
     w.addDocuments(docs);
 
     // This doc will not be included, because it doesn't have nested docs
-    document = new Document();
-    document.add(new StringField("__type", "parent", Field.Store.NO));
-    document.add(new StringField("field1", "h", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("__type", "parent");
+    document.addAtom("field1", "h");
     w.addDocument(document);
 
     docs.clear();
-    document = new Document();
-    document.add(new StringField("field2", "m", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("m")));
-    document.add(new StringField("filter_1", "T", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "n", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("n")));
-    document.add(new StringField("filter_1", "F", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("field2", "o", Field.Store.NO));
-    document.add(new SortedDocValuesField("field2", new BytesRef("o")));
-    document.add(new StringField("filter_1", "F", Field.Store.NO));
-    docs.add(document);
-    document = new Document();
-    document.add(new StringField("__type", "parent", Field.Store.NO));
-    document.add(new StringField("field1", "i", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("field2", "m");
+    document.addAtom("filter_1", "T");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "n");
+    document.addAtom("filter_1", "F");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("field2", "o");
+    document.addAtom("filter_1", "F");
+    docs.add(document);
+    document = w.newDocument();
+    document.addAtom("__type", "parent");
+    document.addAtom("field1", "i");
     docs.add(document);
     w.addDocuments(docs);
     w.commit();
 
     // Some garbage docs, just to check if the NestedFieldComparator can deal with this.
-    document = new Document();
-    document.add(new StringField("fieldXXX", "x", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("fieldXXX", "x");
     w.addDocument(document);
-    document = new Document();
-    document.add(new StringField("fieldXXX", "x", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("fieldXXX", "x");
     w.addDocument(document);
-    document = new Document();
-    document.add(new StringField("fieldXXX", "x", Field.Store.NO));
+    document = w.newDocument();
+    document.addAtom("fieldXXX", "x");
     w.addDocument(document);
 
     IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(w.w, false));

Modified: lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java (original)
+++ lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java Sun Nov 30 11:07:09 2014
@@ -22,7 +22,6 @@ import java.util.List;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
@@ -64,7 +63,7 @@ public class TestBlockJoinValidation ext
     final IndexWriterConfig config = new IndexWriterConfig(new MockAnalyzer(random()));
     final IndexWriter indexWriter = new IndexWriter(directory, config);
     for (int i = 0; i < AMOUNT_OF_SEGMENTS; i++) {
-      List<Document> segmentDocs = createDocsForSegment(i);
+      List<Document> segmentDocs = createDocsForSegment(indexWriter, i);
       indexWriter.addDocuments(segmentDocs);
       indexWriter.commit();
     }
@@ -138,10 +137,10 @@ public class TestBlockJoinValidation ext
     directory.close();
   }
 
-  private static List<Document> createDocsForSegment(int segmentNumber) {
+  private static List<Document> createDocsForSegment(IndexWriter w, int segmentNumber) {
     List<List<Document>> blocks = new ArrayList<>(AMOUNT_OF_PARENT_DOCS);
     for (int i = 0; i < AMOUNT_OF_PARENT_DOCS; i++) {
-      blocks.add(createParentDocWithChildren(segmentNumber, i));
+      blocks.add(createParentDocWithChildren(w, segmentNumber, i));
     }
     List<Document> result = new ArrayList<>(AMOUNT_OF_DOCS_IN_SEGMENT);
     for (List<Document> block : blocks) {
@@ -150,26 +149,26 @@ public class TestBlockJoinValidation ext
     return result;
   }
 
-  private static List<Document> createParentDocWithChildren(int segmentNumber, int parentNumber) {
+  private static List<Document> createParentDocWithChildren(IndexWriter w, int segmentNumber, int parentNumber) {
     List<Document> result = new ArrayList<>(AMOUNT_OF_CHILD_DOCS + 1);
     for (int i = 0; i < AMOUNT_OF_CHILD_DOCS; i++) {
-      result.add(createChildDoc(segmentNumber, parentNumber, i));
+      result.add(createChildDoc(w, segmentNumber, parentNumber, i));
     }
-    result.add(createParentDoc(segmentNumber, parentNumber));
+    result.add(createParentDoc(w, segmentNumber, parentNumber));
     return result;
   }
 
-  private static Document createParentDoc(int segmentNumber, int parentNumber) {
-    Document result = new Document();
-    result.add(newStringField("id", createFieldValue(segmentNumber * AMOUNT_OF_PARENT_DOCS + parentNumber), Field.Store.YES));
-    result.add(newStringField("parent", createFieldValue(parentNumber), Field.Store.NO));
+  private static Document createParentDoc(IndexWriter w, int segmentNumber, int parentNumber) {
+    Document result = w.newDocument();
+    result.addAtom("id", createFieldValue(segmentNumber * AMOUNT_OF_PARENT_DOCS + parentNumber));
+    result.addAtom("parent", createFieldValue(parentNumber));
     return result;
   }
 
-  private static Document createChildDoc(int segmentNumber, int parentNumber, int childNumber) {
-    Document result = new Document();
-    result.add(newStringField("id", createFieldValue(segmentNumber * AMOUNT_OF_PARENT_DOCS + parentNumber, childNumber), Field.Store.YES));
-    result.add(newStringField("child", createFieldValue(childNumber), Field.Store.NO));
+  private static Document createChildDoc(IndexWriter w, int segmentNumber, int parentNumber, int childNumber) {
+    Document result = w.newDocument();
+    result.addAtom("id", createFieldValue(segmentNumber * AMOUNT_OF_PARENT_DOCS + parentNumber, childNumber));
+    result.addAtom("child", createFieldValue(childNumber));
     return result;
   }