lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1635898 [3/6] - in /lucene/dev/branches/lucene6005/lucene: analysis/common/src/test/org/apache/lucene/collation/ analysis/icu/src/test/org/apache/lucene/collation/ analysis/uima/src/test/org/apache/lucene/analysis/uima/ backward-codecs/src...
Date Sat, 01 Nov 2014 08:39:30 GMT
Modified: lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java Sat Nov  1 08:39:27 2014
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
@@ -35,27 +36,36 @@ final class StandardDirectoryReader exte
   private final IndexWriter writer;
   private final SegmentInfos segmentInfos;
   private final boolean applyAllDeletes;
+  private final FieldTypes fieldTypes;
   
   /** called only from static open() methods */
-  StandardDirectoryReader(Directory directory, LeafReader[] readers, IndexWriter writer,
-    SegmentInfos sis, boolean applyAllDeletes) {
+  StandardDirectoryReader(FieldTypes fieldTypes, Directory directory, LeafReader[] readers, IndexWriter writer,
+    SegmentInfos sis, boolean applyAllDeletes) throws IOException {
     super(directory, readers);
+    this.fieldTypes = fieldTypes;
     this.writer = writer;
     this.segmentInfos = sis;
     this.applyAllDeletes = applyAllDeletes;
   }
 
+  @Override
+  public FieldTypes getFieldTypes() {
+    return fieldTypes;
+  }
+
   /** called from DirectoryReader.open(...) methods */
   static DirectoryReader open(final Directory directory, final IndexCommit commit) throws IOException {
     return new SegmentInfos.FindSegmentsFile<DirectoryReader>(directory) {
       @Override
       protected DirectoryReader doBody(String segmentFileName) throws IOException {
         SegmentInfos sis = SegmentInfos.readCommit(directory, segmentFileName);
+        // nocommit fixme: can't be passing null analyzers
+        FieldTypes fieldTypes = FieldTypes.getFieldTypes(sis.getUserData(), null, null);
         final SegmentReader[] readers = new SegmentReader[sis.size()];
         for (int i = sis.size()-1; i >= 0; i--) {
           boolean success = false;
           try {
-            readers[i] = new SegmentReader(sis.info(i), IOContext.READ);
+            readers[i] = new SegmentReader(fieldTypes, sis.info(i), IOContext.READ);
             success = true;
           } finally {
             if (!success) {
@@ -63,7 +73,7 @@ final class StandardDirectoryReader exte
             }
           }
         }
-        return new StandardDirectoryReader(directory, readers, null, sis, false);
+        return new StandardDirectoryReader(fieldTypes, directory, readers, null, sis, false);
       }
     }.run(commit);
   }
@@ -79,6 +89,13 @@ final class StandardDirectoryReader exte
     final Directory dir = writer.getDirectory();
 
     final SegmentInfos segmentInfos = infos.clone();
+
+    // Carry over current schema:
+    segmentInfos.getUserData().put(FieldTypes.FIELD_TYPES_KEY, writer.fieldTypes.writeToString());
+
+    // nocommit fixme: can't be passing null analyzers
+    FieldTypes fieldTypes = FieldTypes.getFieldTypes(segmentInfos.getUserData(), null, null);
+
     int infosUpto = 0;
     boolean success = false;
     try {
@@ -91,6 +108,7 @@ final class StandardDirectoryReader exte
         assert info.info.dir == dir;
         final ReadersAndUpdates rld = writer.readerPool.get(info, true);
         try {
+          // nocommit this has writer's fieldTypes, not ours:
           final SegmentReader reader = rld.getReadOnlyClone(IOContext.READ);
           if (reader.numDocs() > 0 || writer.getKeepFullyDeletedSegments()) {
             // Steal the ref:
@@ -107,7 +125,7 @@ final class StandardDirectoryReader exte
       
       writer.incRefDeleter(segmentInfos);
       
-      StandardDirectoryReader result = new StandardDirectoryReader(dir,
+      StandardDirectoryReader result = new StandardDirectoryReader(fieldTypes, dir,
           readers.toArray(new SegmentReader[readers.size()]), writer,
           segmentInfos, applyAllDeletes);
       success = true;
@@ -142,7 +160,10 @@ final class StandardDirectoryReader exte
     }
     
     SegmentReader[] newReaders = new SegmentReader[infos.size()];
-    
+
+    // nocommit fixme: can't be passing null analyzers
+    FieldTypes fieldTypes = FieldTypes.getFieldTypes(infos.getUserData(), null, null);
+
     for (int i = infos.size() - 1; i>=0; i--) {
       SegmentCommitInfo commitInfo = infos.info(i);
 
@@ -163,7 +184,7 @@ final class StandardDirectoryReader exte
         if (oldReader == null || commitInfo.info.getUseCompoundFile() != oldReader.getSegmentInfo().info.getUseCompoundFile()) {
 
           // this is a new reader; in case we hit an exception we can decRef it safely
-          newReader = new SegmentReader(commitInfo, IOContext.READ);
+          newReader = new SegmentReader(fieldTypes, commitInfo, IOContext.READ);
           newReaders[i] = newReader;
         } else {
           if (oldReader.getSegmentInfo().getDelGen() == commitInfo.getDelGen()
@@ -191,10 +212,10 @@ final class StandardDirectoryReader exte
 
             if (oldReader.getSegmentInfo().getDelGen() == commitInfo.getDelGen()) {
               // only DV updates
-              newReaders[i] = new SegmentReader(commitInfo, oldReader, oldReader.getLiveDocs(), oldReader.numDocs());
+              newReaders[i] = new SegmentReader(fieldTypes, commitInfo, oldReader, oldReader.getLiveDocs(), oldReader.numDocs());
             } else {
               // both DV and liveDocs have changed
-              newReaders[i] = new SegmentReader(commitInfo, oldReader);
+              newReaders[i] = new SegmentReader(fieldTypes, commitInfo, oldReader);
             }
           }
         }
@@ -205,7 +226,8 @@ final class StandardDirectoryReader exte
         }
       }
     }    
-    return new StandardDirectoryReader(directory, newReaders, null, infos, false);
+
+    return new StandardDirectoryReader(fieldTypes, directory, newReaders, null, infos, false);
   }
 
   // TODO: move somewhere shared if it's useful elsewhere

Modified: lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/StoredFieldVisitor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/StoredFieldVisitor.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/StoredFieldVisitor.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/StoredFieldVisitor.java Sat Nov  1 08:39:27 2014
@@ -20,7 +20,7 @@ package org.apache.lucene.index;
 import java.io.IOException;
 
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.DocumentStoredFieldVisitor;
+import org.apache.lucene.document.Document2StoredFieldVisitor; // javadocs
 
 /**
  * Expert: provides a low-level means of accessing the stored field
@@ -33,7 +33,7 @@ import org.apache.lucene.document.Docume
  * fields for most codecs is not reeentrant and you will see
  * strange exceptions as a result.
  *
- * <p>See {@link DocumentStoredFieldVisitor}, which is a
+ * <p>See {@link Document2StoredFieldVisitor}, which is a
  * <code>StoredFieldVisitor</code> that builds the
  * {@link Document} containing all stored fields.  This is
  * used by {@link IndexReader#document(int)}.
@@ -93,4 +93,4 @@ public abstract class StoredFieldVisitor
     /** STOP: don't visit this field and stop processing any other fields for this document. */
     STOP
   }
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/TrackingIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/TrackingIndexWriter.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/TrackingIndexWriter.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/index/TrackingIndexWriter.java Sat Nov  1 08:39:27 2014
@@ -48,18 +48,18 @@ public class TrackingIndexWriter {
   }
 
   /** Calls {@link
-   *  IndexWriter#updateDocument(Term,IndexDocument,Analyzer)}
+   *  IndexWriter#updateDocument(Term,Iterable,Analyzer)}
    *  and returns the generation that reflects this change. */
-  public long updateDocument(Term t, IndexDocument d, Analyzer a) throws IOException {
+  public long updateDocument(Term t, Iterable<? extends IndexableField> d, Analyzer a) throws IOException {
     writer.updateDocument(t, d, a);
     // Return gen as of when indexing finished:
     return indexingGen.get();
   }
 
   /** Calls {@link
-   *  IndexWriter#updateDocument(Term,IndexDocument)} and
+   *  IndexWriter#updateDocument(Term,Iterable)} and
    *  returns the generation that reflects this change. */
-  public long updateDocument(Term t, IndexDocument d) throws IOException {
+  public long updateDocument(Term t, Iterable<? extends IndexableField> d) throws IOException {
     writer.updateDocument(t, d);
     // Return gen as of when indexing finished:
     return indexingGen.get();
@@ -68,7 +68,7 @@ public class TrackingIndexWriter {
   /** Calls {@link
    *  IndexWriter#updateDocuments(Term,Iterable,Analyzer)}
    *  and returns the generation that reflects this change. */
-  public long updateDocuments(Term t, Iterable<? extends IndexDocument> docs, Analyzer a) throws IOException {
+  public long updateDocuments(Term t, Iterable<? extends Iterable<? extends IndexableField>> docs, Analyzer a) throws IOException {
     writer.updateDocuments(t, docs, a);
     // Return gen as of when indexing finished:
     return indexingGen.get();
@@ -77,7 +77,7 @@ public class TrackingIndexWriter {
   /** Calls {@link
    *  IndexWriter#updateDocuments(Term,Iterable)} and returns
    *  the generation that reflects this change. */
-  public long updateDocuments(Term t, Iterable<? extends IndexDocument> docs) throws IOException {
+  public long updateDocuments(Term t, Iterable<? extends Iterable<? extends IndexableField>> docs) throws IOException {
     writer.updateDocuments(t, docs);
     // Return gen as of when indexing finished:
     return indexingGen.get();
@@ -124,9 +124,9 @@ public class TrackingIndexWriter {
   }
 
   /** Calls {@link
-   *  IndexWriter#addDocument(IndexDocument,Analyzer)} and
+   *  IndexWriter#addDocument(Iterable,Analyzer)} and
    *  returns the generation that reflects this change. */
-  public long addDocument(IndexDocument d, Analyzer a) throws IOException {
+  public long addDocument(Iterable<? extends IndexableField> d, Analyzer a) throws IOException {
     writer.addDocument(d, a);
     // Return gen as of when indexing finished:
     return indexingGen.get();
@@ -135,15 +135,15 @@ public class TrackingIndexWriter {
   /** Calls {@link
    *  IndexWriter#addDocuments(Iterable,Analyzer)} and
    *  returns the generation that reflects this change.  */
-  public long addDocuments(Iterable<? extends IndexDocument> docs, Analyzer a) throws IOException {
+  public long addDocuments(Iterable<? extends Iterable<? extends IndexableField>> docs, Analyzer a) throws IOException {
     writer.addDocuments(docs, a);
     // Return gen as of when indexing finished:
     return indexingGen.get();
   }
 
-  /** Calls {@link IndexWriter#addDocument(IndexDocument)}
+  /** Calls {@link IndexWriter#addDocument(Iterable)}
    *  and returns the generation that reflects this change. */
-  public long addDocument(IndexDocument d) throws IOException {
+  public long addDocument(Iterable<? extends IndexableField> d) throws IOException {
     writer.addDocument(d);
     // Return gen as of when indexing finished:
     return indexingGen.get();
@@ -151,7 +151,7 @@ public class TrackingIndexWriter {
 
   /** Calls {@link IndexWriter#addDocuments(Iterable)} and
    *  returns the generation that reflects this change. */
-  public long addDocuments(Iterable<? extends IndexDocument> docs) throws IOException {
+  public long addDocuments(Iterable<? extends Iterable<? extends IndexableField>> docs) throws IOException {
     writer.addDocuments(docs);
     // Return gen as of when indexing finished:
     return indexingGen.get();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java Sat Nov  1 08:39:27 2014
@@ -32,13 +32,15 @@ import java.util.concurrent.ExecutorServ
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.document.Document2;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.index.DirectoryReader; // javadocs
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.index.IndexReaderContext;
+import org.apache.lucene.index.IndexWriter; // javadocs
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.index.ReaderUtil;
-import org.apache.lucene.index.StoredDocument;
 import org.apache.lucene.index.StoredFieldVisitor;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
@@ -47,7 +49,6 @@ import org.apache.lucene.search.similari
 import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.store.NIOFSDirectory;    // javadoc
 import org.apache.lucene.util.ThreadInterruptedException;
-import org.apache.lucene.index.IndexWriter; // javadocs
 
 /** Implements search over a single IndexReader.
  *
@@ -181,10 +182,10 @@ public class IndexSearcher {
   }
 
   /** 
-   * Sugar for <code>.getIndexReader().document(docID)</code> 
-   * @see IndexReader#document(int) 
+   * Sugar for <code>.getIndexReader().document2(docID)</code> 
+   * @see IndexReader#document2(int) 
    */
-  public StoredDocument doc(int docID) throws IOException {
+  public Document2 doc(int docID) throws IOException {
     return reader.document(docID);
   }
 
@@ -200,7 +201,7 @@ public class IndexSearcher {
    * Sugar for <code>.getIndexReader().document(docID, fieldsToLoad)</code>
    * @see IndexReader#document(int, Set) 
    */
-  public StoredDocument doc(int docID, Set<String> fieldsToLoad) throws IOException {
+  public Document2 doc(int docID, Set<String> fieldsToLoad) throws IOException {
     return reader.document(docID, fieldsToLoad);
   }
 

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestDemo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestDemo.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestDemo.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestDemo.java Sat Nov  1 08:39:27 2014
@@ -27,7 +27,6 @@ import org.apache.lucene.document.Field;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.index.StoredDocument;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.*;
 import org.apache.lucene.store.Directory;
@@ -66,8 +65,8 @@ public class TestDemo extends LuceneTest
     assertEquals(1, hits.totalHits);
     // Iterate through the results:
     for (int i = 0; i < hits.scoreDocs.length; i++) {
-      StoredDocument hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
-      assertEquals(text, hitDoc.get("fieldname"));
+      Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+      assertEquals(text, hitDoc.getString("fieldname"));
     }
 
     // Test simple phrase query

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestSearch.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestSearch.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestSearch.java Sat Nov  1 08:39:27 2014
@@ -150,8 +150,8 @@ public class TestSearch extends LuceneTe
 
         out.println(hits.length + " total results");
         for (int i = 0 ; i < hits.length && i < 10; i++) {
-          StoredDocument d = searcher.doc(hits[i].doc);
-          out.println(i + " " + hits[i].score + " " + d.get("contents"));
+          Document2 d = searcher.doc(hits[i].doc);
+          out.println(i + " " + hits[i].score + " " + d.getString("contents"));
         }
       }
       reader.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java Sat Nov  1 08:39:27 2014
@@ -47,77 +47,77 @@ public class TestSearchForDuplicates ext
    *        validate this output and make any changes to the checkHits method.
    */
   public void testRun() throws Exception {
-      StringWriter sw = new StringWriter();
-      PrintWriter pw = new PrintWriter(sw, true);
-      final int MAX_DOCS = atLeast(225);
-      doTest(random(), pw, false, MAX_DOCS);
-      pw.close();
-      sw.close();
-      String multiFileOutput = sw.toString();
-      //System.out.println(multiFileOutput);
-
-      sw = new StringWriter();
-      pw = new PrintWriter(sw, true);
-      doTest(random(), pw, true, MAX_DOCS);
-      pw.close();
-      sw.close();
-      String singleFileOutput = sw.toString();
+    StringWriter sw = new StringWriter();
+    PrintWriter pw = new PrintWriter(sw, true);
+    final int MAX_DOCS = atLeast(225);
+    doTest(random(), pw, false, MAX_DOCS);
+    pw.close();
+    sw.close();
+    String multiFileOutput = sw.toString();
+    //System.out.println(multiFileOutput);
+
+    sw = new StringWriter();
+    pw = new PrintWriter(sw, true);
+    doTest(random(), pw, true, MAX_DOCS);
+    pw.close();
+    sw.close();
+    String singleFileOutput = sw.toString();
 
-      assertEquals(multiFileOutput, singleFileOutput);
+    assertEquals(multiFileOutput, singleFileOutput);
   }
 
 
   private void doTest(Random random, PrintWriter out, boolean useCompoundFiles, int MAX_DOCS) throws Exception {
-      Directory directory = newDirectory();
-      Analyzer analyzer = new MockAnalyzer(random);
-      IndexWriterConfig conf = newIndexWriterConfig(analyzer);
-      final MergePolicy mp = conf.getMergePolicy();
-      mp.setNoCFSRatio(useCompoundFiles ? 1.0 : 0.0);
-      IndexWriter writer = new IndexWriter(directory, conf);
-      if (VERBOSE) {
-        System.out.println("TEST: now build index MAX_DOCS=" + MAX_DOCS);
-      }
+    Directory directory = newDirectory();
+    Analyzer analyzer = new MockAnalyzer(random);
+    IndexWriterConfig conf = newIndexWriterConfig(analyzer);
+    final MergePolicy mp = conf.getMergePolicy();
+    mp.setNoCFSRatio(useCompoundFiles ? 1.0 : 0.0);
+    IndexWriter writer = new IndexWriter(directory, conf);
+    if (VERBOSE) {
+      System.out.println("TEST: now build index MAX_DOCS=" + MAX_DOCS);
+    }
 
-      for (int j = 0; j < MAX_DOCS; j++) {
-        Document2 d = writer.newDocument();
-        d.addLargeText(PRIORITY_FIELD, HIGH_PRIORITY);
-        d.addInt(ID_FIELD, j);
-        writer.addDocument(d);
-      }
-      writer.close();
+    for (int j = 0; j < MAX_DOCS; j++) {
+      Document2 d = writer.newDocument();
+      d.addLargeText(PRIORITY_FIELD, HIGH_PRIORITY);
+      d.addInt(ID_FIELD, j);
+      writer.addDocument(d);
+    }
+    writer.close();
 
-      // try a search without OR
-      IndexReader reader = DirectoryReader.open(directory);
-      IndexSearcher searcher = newSearcher(reader);
-
-      Query query = new TermQuery(new Term(PRIORITY_FIELD, HIGH_PRIORITY));
-      out.println("Query: " + query.toString(PRIORITY_FIELD));
-      if (VERBOSE) {
-        System.out.println("TEST: search query=" + query);
-      }
+    // try a search without OR
+    IndexReader reader = DirectoryReader.open(directory);
+    IndexSearcher searcher = newSearcher(reader);
+
+    Query query = new TermQuery(new Term(PRIORITY_FIELD, HIGH_PRIORITY));
+    out.println("Query: " + query.toString(PRIORITY_FIELD));
+    if (VERBOSE) {
+      System.out.println("TEST: search query=" + query);
+    }
 
-      final Sort sort = new Sort(SortField.FIELD_SCORE,
-                                 new SortField(ID_FIELD, SortField.Type.INT));
+    final Sort sort = new Sort(SortField.FIELD_SCORE,
+                               new SortField(ID_FIELD, SortField.Type.INT));
 
-      ScoreDoc[] hits = searcher.search(query, null, MAX_DOCS, sort).scoreDocs;
-      printHits(out, hits, searcher);
-      checkHits(hits, MAX_DOCS, searcher);
-
-      // try a new search with OR
-      searcher = newSearcher(reader);
-      hits = null;
-
-      BooleanQuery booleanQuery = new BooleanQuery();
-      booleanQuery.add(new TermQuery(new Term(PRIORITY_FIELD, HIGH_PRIORITY)), BooleanClause.Occur.SHOULD);
-      booleanQuery.add(new TermQuery(new Term(PRIORITY_FIELD, MED_PRIORITY)), BooleanClause.Occur.SHOULD);
-      out.println("Query: " + booleanQuery.toString(PRIORITY_FIELD));
-
-      hits = searcher.search(booleanQuery, null, MAX_DOCS, sort).scoreDocs;
-      printHits(out, hits, searcher);
-      checkHits(hits, MAX_DOCS, searcher);
+    ScoreDoc[] hits = searcher.search(query, null, MAX_DOCS, sort).scoreDocs;
+    printHits(out, hits, searcher);
+    checkHits(hits, MAX_DOCS, searcher);
+
+    // try a new search with OR
+    searcher = newSearcher(reader);
+    hits = null;
+
+    BooleanQuery booleanQuery = new BooleanQuery();
+    booleanQuery.add(new TermQuery(new Term(PRIORITY_FIELD, HIGH_PRIORITY)), BooleanClause.Occur.SHOULD);
+    booleanQuery.add(new TermQuery(new Term(PRIORITY_FIELD, MED_PRIORITY)), BooleanClause.Occur.SHOULD);
+    out.println("Query: " + booleanQuery.toString(PRIORITY_FIELD));
+
+    hits = searcher.search(booleanQuery, null, MAX_DOCS, sort).scoreDocs;
+    printHits(out, hits, searcher);
+    checkHits(hits, MAX_DOCS, searcher);
 
-      reader.close();
-      directory.close();
+    reader.close();
+    directory.close();
   }
 
 
@@ -125,8 +125,8 @@ public class TestSearchForDuplicates ext
     out.println(hits.length + " total results\n");
     for (int i = 0 ; i < hits.length; i++) {
       if ( i < 10 || (i > 94 && i < 105) ) {
-        StoredDocument d = searcher.doc(hits[i].doc);
-        out.println(i + " " + d.get(ID_FIELD));
+        Document2 d = searcher.doc(hits[i].doc);
+        out.println(i + " " + d.getInt(ID_FIELD));
       }
     }
   }
@@ -135,10 +135,9 @@ public class TestSearchForDuplicates ext
     assertEquals("total results", expectedCount, hits.length);
     for (int i = 0 ; i < hits.length; i++) {
       if (i < 10 || (i > 94 && i < 105) ) {
-        StoredDocument d = searcher.doc(hits[i].doc);
-        assertEquals("check " + i, String.valueOf(i), d.get(ID_FIELD));
+        Document2 d = searcher.doc(hits[i].doc);
+        assertEquals("check " + i, i, d.getInt(ID_FIELD).intValue());
       }
     }
   }
-
 }

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat2.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat2.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat2.java Sat Nov  1 08:39:27 2014
@@ -27,6 +27,7 @@ import org.apache.lucene.index.FieldInfo
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
@@ -83,8 +84,8 @@ public class TestBlockPostingsFormat2 ex
   public void testDFBlockSize() throws Exception {
     Document doc = newDocument();
     for (int i = 0; i < Lucene50PostingsFormat.BLOCK_SIZE; i++) {
-      for (Field f : doc.getFields()) {
-        f.setStringValue(f.name() + " " + f.name() + "_2");
+      for (IndexableField f : doc.getFields()) {
+        ((Field) f).setStringValue(f.name() + " " + f.name() + "_2");
       }
       iw.addDocument(doc);
     }
@@ -94,8 +95,8 @@ public class TestBlockPostingsFormat2 ex
   public void testDFBlockSizeMultiple() throws Exception {
     Document doc = newDocument();
     for (int i = 0; i < Lucene50PostingsFormat.BLOCK_SIZE * 16; i++) {
-      for (Field f : doc.getFields()) {
-        f.setStringValue(f.name() + " " + f.name() + "_2");
+      for (IndexableField f : doc.getFields()) {
+        ((Field) f).setStringValue(f.name() + " " + f.name() + "_2");
       }
       iw.addDocument(doc);
     }
@@ -105,8 +106,8 @@ public class TestBlockPostingsFormat2 ex
   public void testTTFBlockSize() throws Exception {
     Document doc = newDocument();
     for (int i = 0; i < Lucene50PostingsFormat.BLOCK_SIZE/2; i++) {
-      for (Field f : doc.getFields()) {
-        f.setStringValue(f.name() + " " + f.name() + " " + f.name() + "_2 " + f.name() + "_2");
+      for (IndexableField f : doc.getFields()) {
+        ((Field) f).setStringValue(f.name() + " " + f.name() + " " + f.name() + "_2 " + f.name() + "_2");
       }
       iw.addDocument(doc);
     }
@@ -116,7 +117,7 @@ public class TestBlockPostingsFormat2 ex
   public void testTTFBlockSizeMultiple() throws Exception {
     Document doc = newDocument();
     for (int i = 0; i < Lucene50PostingsFormat.BLOCK_SIZE/2; i++) {
-      for (Field f : doc.getFields()) {
+      for (IndexableField f : doc.getFields()) {
         String proto = (f.name() + " " + f.name() + " " + f.name() + " " + f.name() + " " 
                        + f.name() + "_2 " + f.name() + "_2 " + f.name() + "_2 " + f.name() + "_2");
         StringBuilder val = new StringBuilder();
@@ -124,7 +125,7 @@ public class TestBlockPostingsFormat2 ex
           val.append(proto);
           val.append(" ");
         }
-        f.setStringValue(val.toString());
+        ((Field) f).setStringValue(val.toString());
       }
       iw.addDocument(doc);
     }

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java Sat Nov  1 08:39:27 2014
@@ -27,6 +27,7 @@ import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.codecs.DocValuesFormat;
 import org.apache.lucene.codecs.asserting.AssertingCodec;
 import org.apache.lucene.document.BinaryDocValuesField;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.NumericDocValuesField;
@@ -38,7 +39,6 @@ import org.apache.lucene.index.IndexWrit
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.NumericDocValues;
 import org.apache.lucene.index.RandomCodec;
-import org.apache.lucene.index.StoredDocument;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
@@ -111,8 +111,8 @@ public class TestPerFieldDocValuesFormat
     assertEquals(1, hits.totalHits);
     // Iterate through the results:
     for (int i = 0; i < hits.scoreDocs.length; i++) {
-      StoredDocument hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
-      assertEquals(text, hitDoc.get("fieldname"));
+      Document2 hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+      assertEquals(text, hitDoc.getString("fieldname"));
       assert ireader.leaves().size() == 1;
       NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv1");
       assertEquals(5, dv.get(hits.scoreDocs[i].doc));

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java Sat Nov  1 08:39:27 2014
@@ -1,14 +1,5 @@
 package org.apache.lucene.document;
 
-import java.nio.charset.StandardCharsets;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.index.StoredDocument;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.LuceneTestCase;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -26,6 +17,14 @@ import org.apache.lucene.util.LuceneTest
  * limitations under the License.
  */
 
+import java.nio.charset.StandardCharsets;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LuceneTestCase;
+
 /**
  * Tests {@link Document} class.
  */
@@ -58,17 +57,17 @@ public class TestBinaryDocument extends 
     
     /** open a reader and fetch the document */ 
     IndexReader reader = writer.getReader();
-    StoredDocument docFromReader = reader.document(0);
+    Document2 docFromReader = reader.document(0);
     assertTrue(docFromReader != null);
     
     /** fetch the binary stored field and compare it's content with the original one */
-    BytesRef bytes = docFromReader.getBinaryValue("binaryStored");
+    BytesRef bytes = docFromReader.getBinary("binaryStored");
     assertNotNull(bytes);
     String binaryFldStoredTest = new String(bytes.bytes, bytes.offset, bytes.length, StandardCharsets.UTF_8);
     assertTrue(binaryFldStoredTest.equals(binaryValStored));
     
     /** fetch the string field and compare it's content with the original one */
-    String stringFldStoredTest = docFromReader.get("stringStored");
+    String stringFldStoredTest = docFromReader.getString("stringStored");
     assertTrue(stringFldStoredTest.equals(binaryValStored));
     
     writer.close();
@@ -92,13 +91,13 @@ public class TestBinaryDocument extends 
     
     /** open a reader and fetch the document */ 
     IndexReader reader = writer.getReader();
-    StoredDocument docFromReader = reader.document(0);
+    Document2 docFromReader = reader.document(0);
     assertTrue(docFromReader != null);
     
     /** fetch the binary compressed field and compare it's content with the original one */
-    String binaryFldCompressedTest = new String(CompressionTools.decompress(docFromReader.getBinaryValue("binaryCompressed")), StandardCharsets.UTF_8);
+    String binaryFldCompressedTest = new String(CompressionTools.decompress(docFromReader.getBinary("binaryCompressed")), StandardCharsets.UTF_8);
     assertTrue(binaryFldCompressedTest.equals(binaryValCompressed));
-    assertTrue(CompressionTools.decompressString(docFromReader.getBinaryValue("stringCompressed")).equals(binaryValCompressed));
+    assertTrue(CompressionTools.decompressString(docFromReader.getBinary("stringCompressed")).equals(binaryValCompressed));
 
     writer.close();
     reader.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestDocument.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestDocument.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestDocument.java Sat Nov  1 08:39:27 2014
@@ -27,9 +27,8 @@ import org.apache.lucene.analysis.Tokeni
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.FieldInfo.IndexOptions;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.index.StorableField;
-import org.apache.lucene.index.StoredDocument;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.PhraseQuery;
@@ -172,7 +171,7 @@ public class TestDocument extends Lucene
   public void testGetFieldsImmutable() {
     Document doc = makeDocumentWithFields();
     assertEquals(10, doc.getFields().size());
-    List<Field> fields = doc.getFields();
+    List<IndexableField> fields = doc.getFields();
     try {
       fields.add( new StringField("name", "value", Field.Store.NO) );
       fail("Document.getFields() should return immutable List");
@@ -279,14 +278,44 @@ public class TestDocument extends Lucene
     return doc;
   }
   
-  private void doAssert(StoredDocument doc) {
-    doAssert(new Document(doc), true);
+  private void doAssert(Document2 doc) {
+    doAssert(doc, true);
   }
+
+  private void doAssert(Document2 doc, boolean fromIndex) {
+    List<IndexableField> keywordFieldValues = doc.getFields("keyword");
+    List<IndexableField> textFieldValues = doc.getFields("text");
+    List<IndexableField> unindexedFieldValues = doc.getFields("unindexed");
+    List<IndexableField> unstoredFieldValues = doc.getFields("unstored");
+    
+    assertTrue(keywordFieldValues.size() == 2);
+    assertTrue(textFieldValues.size() == 2);
+    assertTrue(unindexedFieldValues.size() == 2);
+    // this test cannot work for documents retrieved from the index
+    // since unstored fields will obviously not be returned
+    if (!fromIndex) {
+      assertTrue(unstoredFieldValues.size() == 2);
+    }
+    
+    assertTrue(keywordFieldValues.get(0).stringValue().equals("test1"));
+    assertTrue(keywordFieldValues.get(1).stringValue().equals("test2"));
+    assertTrue(textFieldValues.get(0).stringValue().equals("test1"));
+    assertTrue(textFieldValues.get(1).stringValue().equals("test2"));
+    assertTrue(unindexedFieldValues.get(0).stringValue().equals("test1"));
+    assertTrue(unindexedFieldValues.get(1).stringValue().equals("test2"));
+    // this test cannot work for documents retrieved from the index
+    // since unstored fields will obviously not be returned
+    if (!fromIndex) {
+      assertTrue(unstoredFieldValues.get(0).stringValue().equals("test1"));
+      assertTrue(unstoredFieldValues.get(1).stringValue().equals("test2"));
+    }
+  }
+
   private void doAssert(Document doc, boolean fromIndex) {
-    StorableField[] keywordFieldValues = doc.getFields("keyword");
-    StorableField[] textFieldValues = doc.getFields("text");
-    StorableField[] unindexedFieldValues = doc.getFields("unindexed");
-    StorableField[] unstoredFieldValues = doc.getFields("unstored");
+    IndexableField[] keywordFieldValues = doc.getFields("keyword");
+    IndexableField[] textFieldValues = doc.getFields("text");
+    IndexableField[] unindexedFieldValues = doc.getFields("unindexed");
+    IndexableField[] unstoredFieldValues = doc.getFields("unstored");
     
     assertTrue(keywordFieldValues.length == 2);
     assertTrue(textFieldValues.length == 2);
@@ -336,8 +365,8 @@ public class TestDocument extends Lucene
     assertEquals(3, hits.length);
     int result = 0;
     for (int i = 0; i < 3; i++) {
-      StoredDocument doc2 = searcher.doc(hits[i].doc);
-      Field f = (Field) doc2.getField("id");
+      Document2 doc2 = searcher.doc(hits[i].doc);
+      IndexableField f = doc2.getField("id");
       if (f.stringValue().equals("id1")) result |= 1;
       else if (f.stringValue().equals("id2")) result |= 2;
       else if (f.stringValue().equals("id3")) result |= 4;
@@ -375,10 +404,10 @@ public class TestDocument extends Lucene
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
     iw.addDocument(doc);
     DirectoryReader ir = iw.getReader();
-    StoredDocument sdoc = ir.document(0);
-    assertEquals("5", sdoc.get("int"));
+    Document2 sdoc = ir.document(0);
+    assertEquals("5", sdoc.getString("int"));
     assertNull(sdoc.get("somethingElse"));
-    assertArrayEquals(new String[] { "5", "4" }, sdoc.getValues("int"));
+    assertArrayEquals(new String[] { "5", "4" }, sdoc.getStrings("int"));
     ir.close();
     iw.close();
     dir.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestDocument2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestDocument2.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestDocument2.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/document/TestDocument2.java Sat Nov  1 08:39:27 2014
@@ -37,7 +37,6 @@ import org.apache.lucene.index.MultiFiel
 import org.apache.lucene.index.NumericDocValues;
 import org.apache.lucene.index.SortedNumericDocValues;
 import org.apache.lucene.index.SortedSetDocValues;
-import org.apache.lucene.index.StoredDocument;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.MatchAllDocsQuery;
@@ -84,7 +83,7 @@ public class TestDocument2 extends Lucen
     w.addDocument(doc);
     IndexReader r = DirectoryReader.open(w, true);
     IndexSearcher s = newSearcher(r);
-    assertEquals(1, s.search(fieldTypes.newTermQuery("binary", new byte[5]), 1).totalHits);
+    assertEquals(1, s.search(fieldTypes.newBinaryTermQuery("binary", new byte[5]), 1).totalHits);
     r.close();
     w.close();
     dir.close();
@@ -131,7 +130,7 @@ public class TestDocument2 extends Lucen
     doc.addStored("binary", new BytesRef(new byte[5]));
     w.addDocument(doc);
     IndexReader r = DirectoryReader.open(w, true);
-    assertEquals(new BytesRef(new byte[5]), r.document(0).getBinaryValue("binary"));
+    assertEquals(new BytesRef(new byte[5]), r.document(0).getBinary("binary"));
     r.close();
     w.close();
     dir.close();
@@ -234,18 +233,18 @@ public class TestDocument2 extends Lucen
     NumericDocValues ndv = MultiDocValues.getNumericValues(r, "float");
     assertNotNull(ndv);
     ScoreDoc hit = hits.scoreDocs[0];
-    StoredDocument storedDoc = r.document(hit.doc);
-    assertEquals("one", storedDoc.get("id"));
+    Document2 storedDoc = r.document(hit.doc);
+    assertEquals("one", storedDoc.getString("id"));
     assertEquals(3f, Float.intBitsToFloat((int) ndv.get(hit.doc)), .001f);
 
     hit = hits.scoreDocs[1];
     storedDoc = r.document(hit.doc);
-    assertEquals("three", storedDoc.get("id"));
+    assertEquals("three", storedDoc.getString("id"));
     assertEquals(7f, Float.intBitsToFloat((int) ndv.get(hit.doc)), .001f);
 
     hit = hits.scoreDocs[2];
     storedDoc = r.document(hit.doc);
-    assertEquals("two", storedDoc.get("id"));
+    assertEquals("two", storedDoc.getString("id"));
     assertEquals(2f, Float.intBitsToFloat((int) ndv.get(hit.doc)), .001f);
 
     // Make sure we can sort by the field:
@@ -574,10 +573,10 @@ public class TestDocument2 extends Lucen
 
     IndexReader r = DirectoryReader.open(w, true);
     IndexSearcher s = newSearcher(r);
-    TopDocs hits = s.search(fieldTypes.newTermQuery("id", "0"), 1);
+    TopDocs hits = s.search(fieldTypes.newStringTermQuery("id", "0"), 1);
     assertEquals(1, hits.scoreDocs.length);
     assertEquals("0", r.document(hits.scoreDocs[0].doc).get("id"));
-    hits = s.search(fieldTypes.newTermQuery("id", "1"), 1);
+    hits = s.search(fieldTypes.newStringTermQuery("id", "1"), 1);
     assertEquals(1, hits.scoreDocs.length);
     assertEquals("1", r.document(hits.scoreDocs[0].doc).get("id"));
     r.close();
@@ -597,7 +596,7 @@ public class TestDocument2 extends Lucen
 
     IndexReader r = DirectoryReader.open(w, true);
     IndexSearcher s = newSearcher(r);
-    TopDocs hits = s.search(fieldTypes.newTermQuery("id", 1L), 1);
+    TopDocs hits = s.search(fieldTypes.newLongTermQuery("id", 1L), 1);
     assertEquals(1, hits.scoreDocs.length);
     r.close();
     w.close();
@@ -616,7 +615,7 @@ public class TestDocument2 extends Lucen
 
     IndexReader r = DirectoryReader.open(w, true);
     IndexSearcher s = newSearcher(r);
-    TopDocs hits = s.search(fieldTypes.newTermQuery("id", 1), 1);
+    TopDocs hits = s.search(fieldTypes.newIntTermQuery("id", 1), 1);
     assertEquals(1, hits.scoreDocs.length);
     r.close();
     w.close();
@@ -636,7 +635,7 @@ public class TestDocument2 extends Lucen
 
     IndexReader r = DirectoryReader.open(w, true);
     IndexSearcher s = newSearcher(r);
-    TopDocs hits = s.search(fieldTypes.newTermQuery("id", new byte[1]), 1);
+    TopDocs hits = s.search(fieldTypes.newBinaryTermQuery("id", new byte[1]), 1);
     assertEquals(1, hits.scoreDocs.length);
     r.close();
     w.close();
@@ -663,10 +662,10 @@ public class TestDocument2 extends Lucen
 
     IndexReader r = DirectoryReader.open(w, true);
     IndexSearcher s = newSearcher(r);
-    TopDocs hits = s.search(fieldTypes.newTermQuery("id", "0"), 1, fieldTypes.newSort("id"));
+    TopDocs hits = s.search(fieldTypes.newStringTermQuery("id", "0"), 1, fieldTypes.newSort("id"));
     assertEquals(1, hits.scoreDocs.length);
     assertEquals("0", r.document(hits.scoreDocs[0].doc).get("id"));
-    hits = s.search(fieldTypes.newTermQuery("id", "1"), 1);
+    hits = s.search(fieldTypes.newStringTermQuery("id", "1"), 1);
     assertEquals(1, hits.scoreDocs.length);
     assertEquals("1", r.document(hits.scoreDocs[0].doc).get("id"));
     r.close();
@@ -836,7 +835,7 @@ public class TestDocument2 extends Lucen
     dir.close();
   }
 
-  public void testFieldTypesAreSaved() throws Exception {
+  public void testExcFieldTypesAreSaved() throws Exception {
     Directory dir = newDirectory();
     IndexWriter w = new IndexWriter(dir, newIndexWriterConfig());
     Document2 doc = w.newDocument();
@@ -872,7 +871,7 @@ public class TestDocument2 extends Lucen
 
     IndexReader r = DirectoryReader.open(w, true);
     try {
-      fieldTypes.newTermQuery("foo", "bar");
+      fieldTypes.newStringTermQuery("foo", "bar");
       fail("did not hit exception");
     } catch (IllegalStateException ise) {
       // Expected
@@ -934,6 +933,46 @@ public class TestDocument2 extends Lucen
     dir.close();
   }
 
+  public void testBooleanType() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriterConfig iwc = newIndexWriterConfig();
+    IndexWriter w = new IndexWriter(dir, iwc);
+
+    FieldTypes fieldTypes = w.getFieldTypes();
+
+    Document2 doc = w.newDocument();
+    doc.addBoolean("onsale", true);
+    w.addDocument(doc);
+
+    //w.close();
+    //DirectoryReader r = DirectoryReader.open(dir);
+    DirectoryReader r = DirectoryReader.open(w, true);
+    IndexSearcher s = newSearcher(r);
+    TopDocs hits = s.search(fieldTypes.newBooleanTermQuery("onsale", true), 1);
+    assertEquals(1, hits.totalHits);
+    doc = s.doc(hits.scoreDocs[0].doc);
+    assertEquals(true, doc.getBoolean("onsale"));
+    assertEquals(0, s.search(fieldTypes.newBooleanTermQuery("onsale", false), 1).totalHits);
+    r.close();
+    w.close();
+    dir.close();
+  }
+
+  public void testOnlyChangeFieldTypes() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriter w = new IndexWriter(dir, newIndexWriterConfig());
+    w.commit();
+    FieldTypes fieldTypes = w.getFieldTypes();
+    fieldTypes.enableSorting("sorted");
+    w.close();
+
+    w = new IndexWriter(dir, newIndexWriterConfig());
+    fieldTypes = w.getFieldTypes();
+    assertTrue(fieldTypes.getSorted("sorted"));
+    w.close();
+    dir.close();
+  }
+
 
   // nocommit test per-field analyzers
 

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java Sat Nov  1 08:39:27 2014
@@ -18,16 +18,16 @@ 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.FieldType;
 import org.apache.lucene.store.MMapDirectory;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TimeUnits;
-import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
-
 import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
 import com.carrotsearch.randomizedtesting.generators.RandomInts;
 
@@ -96,10 +96,10 @@ public class Test4GBStoredFields extends
     }
 
     DirectoryReader rd = DirectoryReader.open(dir);
-    StoredDocument sd = rd.document(numDocs - 1);
+    Document2 sd = rd.document(numDocs - 1);
     assertNotNull(sd);
     assertEquals(1, sd.getFields().size());
-    BytesRef valueRef = sd.getBinaryValue("fld");
+    BytesRef valueRef = sd.getBinary("fld");
     assertNotNull(valueRef);
     assertEquals(new BytesRef(value), valueRef);
     rd.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java Sat Nov  1 08:39:27 2014
@@ -1207,11 +1207,11 @@ public class TestAddIndexes extends Luce
     w.close();
     assertEquals(2, r3.numDocs());
     for(int docID=0;docID<2;docID++) {
-      StoredDocument d = r3.document(docID);
-      if (d.get("id").equals("1")) {
-        assertEquals("doc1 field1", d.get("f1"));
+      Document2 d = r3.document(docID);
+      if (d.getString("id").equals("1")) {
+        assertEquals("doc1 field1", d.getString("f1"));
       } else {
-        assertEquals("doc2 field2", d.get("f2"));
+        assertEquals("doc2 field2", d.getString("f2"));
       }
     }
     r3.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java Sat Nov  1 08:39:27 2014
@@ -19,6 +19,7 @@ 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.TextField;
@@ -70,8 +71,8 @@ public class TestCustomNorms extends Luc
     NumericDocValues norms = open.getNormValues(floatTestField);
     assertNotNull(norms);
     for (int i = 0; i < open.maxDoc(); i++) {
-      StoredDocument document = open.document(i);
-      float expected = Float.parseFloat(document.get(floatTestField));
+      Document2 document = open.document(i);
+      float expected = Float.parseFloat(document.getString(floatTestField));
       assertEquals(expected, Float.intBitsToFloat((int)norms.get(i)), 0.0f);
     }
     open.close();

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=1635898&r1=1635897&r2=1635898&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 Sat Nov  1 08:39:27 2014
@@ -56,10 +56,10 @@ public class TestDirectoryReader extends
     assertTrue(reader instanceof StandardDirectoryReader);
     FieldTypes fieldTypes = FieldTypes.getFieldTypes(reader.getIndexCommit(), new MockAnalyzer(random()));
     Set<String> unstored = DocHelper.getUnstored(fieldTypes);
-    StoredDocument newDoc1 = reader.document(0);
+    Document2 newDoc1 = reader.document(0);
     assertTrue(newDoc1 != null);
     assertEquals(DocHelper.numFields() - unstored.size(), DocHelper.numFields(newDoc1));
-    StoredDocument newDoc2 = reader.document(1);
+    Document2 newDoc2 = reader.document(1);
     assertTrue(newDoc2 != null);
     assertTrue(DocHelper.numFields(newDoc2) == DocHelper.numFields() - unstored.size());
     Terms vector = reader.getTermVectors(0).terms(DocHelper.TEXT_FIELD_2_KEY);
@@ -373,11 +373,11 @@ public class TestDirectoryReader extends
     writer.addDocument(doc);
     writer.close();
     DirectoryReader reader = DirectoryReader.open(dir);
-    StoredDocument doc2 = reader.document(reader.maxDoc() - 1);
-    StorableField[] fields = doc2.getFields("bin1");
+    Document2 doc2 = reader.document(reader.maxDoc() - 1);
+    List<IndexableField> fields = doc2.getFields("bin1");
     assertNotNull(fields);
-    assertEquals(1, fields.length);
-    StorableField b1 = fields[0];
+    assertEquals(1, fields.size());
+    IndexableField b1 = fields.get(0);
     assertTrue(b1.binaryValue() != null);
     BytesRef bytesRef = b1.binaryValue();
     assertEquals(bin.length, bytesRef.length);
@@ -397,8 +397,8 @@ public class TestDirectoryReader extends
     doc2 = reader.document(reader.maxDoc() - 1);
     fields = doc2.getFields("bin1");
     assertNotNull(fields);
-    assertEquals(1, fields.length);
-    b1 = fields[0];
+    assertEquals(1, fields.size());
+    b1 = fields.get(0);
     assertTrue(b1.binaryValue() != null);
     bytesRef = b1.binaryValue();
     assertEquals(bin.length, bytesRef.length);
@@ -577,16 +577,16 @@ public class TestDirectoryReader extends
     // check stored fields
     for (int i = 0; i < index1.maxDoc(); i++) {
       if (liveDocs1 == null || liveDocs1.get(i)) {
-        StoredDocument doc1 = index1.document(i);
-        StoredDocument doc2 = index2.document(i);
-        List<StorableField> field1 = doc1.getFields();
-        List<StorableField> field2 = doc2.getFields();
+        Document2 doc1 = index1.document(i);
+        Document2 doc2 = index2.document(i);
+        List<IndexableField> field1 = doc1.getFields();
+        List<IndexableField> field2 = doc2.getFields();
         assertEquals("Different numbers of fields for doc " + i + ".", field1.size(), field2.size());
-        Iterator<StorableField> itField1 = field1.iterator();
-        Iterator<StorableField> itField2 = field2.iterator();
+        Iterator<IndexableField> itField1 = field1.iterator();
+        Iterator<IndexableField> itField2 = field2.iterator();
         while (itField1.hasNext()) {
-          Field curField1 = (Field) itField1.next();
-          Field curField2 = (Field) itField2.next();
+          IndexableField curField1 = itField1.next();
+          IndexableField curField2 = itField2.next();
           assertEquals("Different fields names for doc " + i + ".", curField1.name(), curField2.name());
           assertEquals("Different field values for doc " + i + ".", curField1.stringValue(), curField2.stringValue());
         }          
@@ -1019,7 +1019,7 @@ public class TestDirectoryReader extends
     Set<String> fieldsToLoad = new HashSet<>();
     assertEquals(0, r.document(0, fieldsToLoad).getFields().size());
     fieldsToLoad.add("field1");
-    StoredDocument doc2 = r.document(0, fieldsToLoad);
+    Document2 doc2 = r.document(0, fieldsToLoad);
     assertEquals(1, doc2.getFields().size());
     assertEquals("foobar", doc2.get("field1"));
     r.close();

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=1635898&r1=1635897&r2=1635898&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 Sat Nov  1 08:39:27 2014
@@ -29,6 +29,7 @@ import java.util.Set;
 
 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.Field;
 import org.apache.lucene.document.FieldType;
@@ -127,9 +128,9 @@ public class TestDirectoryReaderReopen e
           if (i>0) {
             int k = i-1;
             int n = j + k*M;
-            StoredDocument prevItereationDoc = reader.document(n);
+            Document2 prevItereationDoc = reader.document(n);
             assertNotNull(prevItereationDoc);
-            String id = prevItereationDoc.get("id");
+            String id = prevItereationDoc.getString("id");
             assertEquals(k+"_"+j, id);
           }
         }

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=1635898&r1=1635897&r2=1635898&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 Sat Nov  1 08:39:27 2014
@@ -34,6 +34,7 @@ import java.util.LinkedList;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.document.Document;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.search.DocIdSetIterator;
@@ -198,53 +199,52 @@ public class TestDoc extends LuceneTestC
    }
 
    private SegmentCommitInfo indexDoc(IndexWriter writer, String fileName)
-   throws Exception
-   {
-      Path path = workDir.resolve(fileName);
-      Document doc = new Document();
-      InputStreamReader is = new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8);
-      doc.add(new TextField("contents", is));
-      writer.addDocument(doc);
-      writer.commit();
-      is.close();
-      return writer.newestSegment();
+     throws Exception {
+     Path path = workDir.resolve(fileName);
+     Document doc = new Document();
+     InputStreamReader is = new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8);
+     doc.add(new TextField("contents", is));
+     writer.addDocument(doc);
+     writer.commit();
+     is.close();
+     return writer.newestSegment();
    }
 
-
    private SegmentCommitInfo merge(Directory dir, SegmentCommitInfo si1, SegmentCommitInfo si2, String merged, boolean useCompoundFile)
-   throws Exception {
-      IOContext context = newIOContext(random());
-      SegmentReader r1 = new SegmentReader(si1, context);
-      SegmentReader r2 = new SegmentReader(si2, context);
-
-      final Codec codec = Codec.getDefault();
-      TrackingDirectoryWrapper trackingDir = new TrackingDirectoryWrapper(si1.info.dir);
-      final SegmentInfo si = new SegmentInfo(si1.info.dir, Version.LATEST, merged, -1, false, codec, null, StringHelper.randomId());
-
-      SegmentMerger merger = new SegmentMerger(Arrays.<LeafReader>asList(r1, r2),
-          si, InfoStream.getDefault(), trackingDir,
-          MergeState.CheckAbort.NONE, new FieldInfos.FieldNumbers(), context);
-
-      MergeState mergeState = merger.merge();
-      r1.close();
-      r2.close();;
-      si.setFiles(new HashSet<>(trackingDir.getCreatedFiles()));
+     throws Exception {
+     FieldTypes fieldTypes = FieldTypes.getFieldTypes(dir, null);
+     IOContext context = newIOContext(random());
+     SegmentReader r1 = new SegmentReader(fieldTypes, si1, context);
+     SegmentReader r2 = new SegmentReader(fieldTypes, si2, context);
+
+     final Codec codec = Codec.getDefault();
+     TrackingDirectoryWrapper trackingDir = new TrackingDirectoryWrapper(si1.info.dir);
+     final SegmentInfo si = new SegmentInfo(si1.info.dir, Version.LATEST, merged, -1, false, codec, null, StringHelper.randomId());
+
+     SegmentMerger merger = new SegmentMerger(fieldTypes, Arrays.<LeafReader>asList(r1, r2),
+                                              si, InfoStream.getDefault(), trackingDir,
+                                              MergeState.CheckAbort.NONE, new FieldInfos.FieldNumbers(), context);
+
+     MergeState mergeState = merger.merge();
+     r1.close();
+     r2.close();;
+     si.setFiles(new HashSet<>(trackingDir.getCreatedFiles()));
       
-      if (useCompoundFile) {
-        Collection<String> filesToDelete = IndexWriter.createCompoundFile(InfoStream.getDefault(), dir, MergeState.CheckAbort.NONE, si, newIOContext(random()));
-        si.setUseCompoundFile(true);
-        for (final String fileToDelete : filesToDelete) {
-          si1.info.dir.deleteFile(fileToDelete);
-        }
-      }
+     if (useCompoundFile) {
+       Collection<String> filesToDelete = IndexWriter.createCompoundFile(InfoStream.getDefault(), dir, MergeState.CheckAbort.NONE, si, newIOContext(random()));
+       si.setUseCompoundFile(true);
+       for (final String fileToDelete : filesToDelete) {
+         si1.info.dir.deleteFile(fileToDelete);
+       }
+     }
 
-      return new SegmentCommitInfo(si, 0, -1L, -1L, -1L);
+     return new SegmentCommitInfo(si, 0, -1L, -1L, -1L);
    }
 
 
    private void printSegment(PrintWriter out, SegmentCommitInfo si)
    throws Exception {
-      SegmentReader reader = new SegmentReader(si, newIOContext(random()));
+      SegmentReader reader = new SegmentReader(null, si, newIOContext(random()));
 
       for (int i = 0; i < reader.numDocs(); i++)
         out.println(reader.document(i));

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=1635898&r1=1635897&r2=1635898&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 Sat Nov  1 08:39:27 2014
@@ -24,9 +24,10 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.BinaryDocValuesField;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
 import org.apache.lucene.document.Field.Store;
+import org.apache.lucene.document.Field;
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.document.SortedDocValuesField;
 import org.apache.lucene.document.SortedSetDocValuesField;
@@ -210,10 +211,10 @@ public class TestDocValuesIndexing exten
     NumericDocValues dv = slow.getNumericDocValues("dv");
     for (int i = 0; i < 50; i++) {
       assertEquals(i, dv.get(i));
-      StoredDocument d = slow.document(i);
+      Document2 d = slow.document(i);
       // cannot use d.get("dv") due to another bug!
-      assertNull(d.getField("dv"));
-      assertEquals(Integer.toString(i), d.get("docId"));
+      assertNull(d.getString("dv"));
+      assertEquals(Integer.toString(i), d.getString("docId"));
     }
     slow.close();
     writer.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java Sat Nov  1 08:39:27 2014
@@ -18,6 +18,7 @@ package org.apache.lucene.index;
  */
 
 import java.io.IOException;
+import java.util.List;
 
 import org.apache.lucene.analysis.*;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@@ -58,35 +59,36 @@ public class TestDocumentWriter extends 
 
   public void testAddDocument() throws Exception {
     SegmentCommitInfo info = DocHelper.writeDoc(random(), dir);
+    FieldTypes fieldTypes = FieldTypes.getFieldTypes(dir, null);
 
     //After adding the document, we should be able to read it back in
-    SegmentReader reader = new SegmentReader(info, newIOContext(random()));
+    SegmentReader reader = new SegmentReader(fieldTypes, info, newIOContext(random()));
     assertTrue(reader != null);
-    StoredDocument doc = reader.document(0);
+    Document2 doc = reader.document(0);
     assertTrue(doc != null);
 
     //System.out.println("Document: " + doc);
-    StorableField[] fields = doc.getFields("textField2");
-    assertTrue(fields != null && fields.length == 1);
-    assertTrue(fields[0].stringValue().equals(DocHelper.FIELD_2_TEXT));
-    assertTrue(fields[0].fieldType().storeTermVectors());
+    List<IndexableField> fields = doc.getFields("textField2");
+    assertTrue(fields != null && fields.size() == 1);
+    assertTrue(fields.get(0).stringValue().equals(DocHelper.FIELD_2_TEXT));
+    assertTrue(fields.get(0).fieldType().storeTermVectors());
 
     fields = doc.getFields("textField1");
-    assertTrue(fields != null && fields.length == 1);
-    assertTrue(fields[0].stringValue().equals(DocHelper.FIELD_1_TEXT));
-    assertFalse(fields[0].fieldType().storeTermVectors());
+    assertTrue(fields != null && fields.size() == 1);
+    assertTrue(fields.get(0).stringValue().equals(DocHelper.FIELD_1_TEXT));
+    assertFalse(fields.get(0).fieldType().storeTermVectors());
 
     fields = doc.getFields("keyField");
-    assertTrue(fields != null && fields.length == 1);
-    assertTrue(fields[0].stringValue().equals(DocHelper.KEYWORD_TEXT));
+    assertTrue(fields != null && fields.size() == 1);
+    assertTrue(fields.get(0).stringValue().equals(DocHelper.KEYWORD_TEXT));
 
     fields = doc.getFields(DocHelper.NO_NORMS_KEY);
-    assertTrue(fields != null && fields.length == 1);
-    assertTrue(fields[0].stringValue().equals(DocHelper.NO_NORMS_TEXT));
+    assertTrue(fields != null && fields.size() == 1);
+    assertTrue(fields.get(0).stringValue().equals(DocHelper.NO_NORMS_TEXT));
 
     fields = doc.getFields(DocHelper.TEXT_FIELD_3_KEY);
-    assertTrue(fields != null && fields.length == 1);
-    assertTrue(fields[0].stringValue().equals(DocHelper.FIELD_3_TEXT));
+    assertTrue(fields != null && fields.size() == 1);
+    assertTrue(fields.get(0).stringValue().equals(DocHelper.FIELD_3_TEXT));
 
     // test that the norms are not present in the segment if
     // omitNorms is true
@@ -121,7 +123,9 @@ public class TestDocumentWriter extends 
     writer.commit();
     SegmentCommitInfo info = writer.newestSegment();
     writer.close();
-    SegmentReader reader = new SegmentReader(info, newIOContext(random()));
+    
+    SegmentReader reader = new SegmentReader(FieldTypes.getFieldTypes(dir, analyzer),
+                                             info, newIOContext(random()));
 
     DocsAndPositionsEnum termPositions = MultiFields.getTermPositionsEnum(reader, MultiFields.getLiveDocs(reader),
                                                                           "repeated", new BytesRef("repeated"));
@@ -193,7 +197,8 @@ public class TestDocumentWriter extends 
     writer.commit();
     SegmentCommitInfo info = writer.newestSegment();
     writer.close();
-    SegmentReader reader = new SegmentReader(info, newIOContext(random()));
+    SegmentReader reader = new SegmentReader(FieldTypes.getFieldTypes(dir, analyzer),
+                                             info, newIOContext(random()));
 
     DocsAndPositionsEnum termPositions = MultiFields.getTermPositionsEnum(reader, reader.getLiveDocs(), "f1", new BytesRef("a"));
     assertTrue(termPositions.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
@@ -235,7 +240,8 @@ public class TestDocumentWriter extends 
     writer.commit();
     SegmentCommitInfo info = writer.newestSegment();
     writer.close();
-    SegmentReader reader = new SegmentReader(info, newIOContext(random()));
+    SegmentReader reader = new SegmentReader(FieldTypes.getFieldTypes(dir, null),
+                                             info, newIOContext(random()));
 
     DocsAndPositionsEnum termPositions = reader.termPositionsEnum(new Term("preanalyzed", "term1"));
     assertTrue(termPositions.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFieldReuse.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFieldReuse.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFieldReuse.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFieldReuse.java Sat Nov  1 08:39:27 2014
@@ -23,14 +23,15 @@ import java.util.Collections;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
 import org.apache.lucene.analysis.CannedTokenStream;
-import org.apache.lucene.analysis.NumericTokenStream;
 import org.apache.lucene.analysis.NumericTokenStream.NumericTermAttribute;
+import org.apache.lucene.analysis.NumericTokenStream;
 import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.IntField;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.NumericUtils;
 
 /** test tokenstream reuse by DefaultIndexingChain */
@@ -119,6 +120,31 @@ public class TestFieldReuse extends Base
       lastSeen = reuse;
       return lastReturned = new CannedTokenStream(new Token("unimportant", 0, 10));
     }
+
+    @Override
+    public String stringValue() {
+      return null;
+    }
+
+    @Override
+    public Number numericValue() {
+      return null;
+    }
+
+    @Override
+    public Number numericDocValue() {
+      return null;
+    }
+
+    @Override
+    public BytesRef binaryDocValue() {
+      return null;
+    }
+
+    @Override
+    public BytesRef binaryValue() {
+      return null;
+    }
     
     @Override
     public float boost() {
@@ -131,30 +157,12 @@ public class TestFieldReuse extends Base
     IndexWriterConfig iwc = new IndexWriterConfig(null);
     IndexWriter iw = new IndexWriter(dir, iwc);
     final MyField field1 = new MyField();
-    iw.addDocument(new IndexDocument() {
-      @Override
-      public Iterable<? extends IndexableField> indexableFields() {
-        return Collections.singletonList(field1);
-      }
-      @Override
-      public Iterable<StorableField> storableFields() {
-        return Collections.emptyList();
-      }
-    });
+    iw.addDocument(Collections.singletonList(field1));
     TokenStream previous = field1.lastReturned;
     assertNotNull(previous);
     
     final MyField field2 = new MyField();
-    iw.addDocument(new IndexDocument() {
-      @Override
-      public Iterable<? extends IndexableField> indexableFields() {
-        return Collections.singletonList(field2);
-      }
-      @Override
-      public Iterable<StorableField> storableFields() {
-        return Collections.emptyList();
-      }
-    });
+    iw.addDocument(Collections.singletonList(field2));
     assertSame(previous, field2.lastSeen);
     iw.close();
     dir.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java Sat Nov  1 08:39:27 2014
@@ -24,9 +24,11 @@ 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.Document2StoredFieldVisitor;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.DocumentStoredFieldVisitor;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.index.FieldInfo.IndexOptions;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.store.BaseDirectory;
@@ -60,32 +62,33 @@ public class TestFieldsReader extends Lu
   public void test() throws IOException {
     assertTrue(dir != null);
     IndexReader reader = DirectoryReader.open(dir);
-    StoredDocument doc = reader.document(0);
+    Document2 doc = reader.document(0);
     assertTrue(doc != null);
     assertTrue(doc.getField(DocHelper.TEXT_FIELD_1_KEY) != null);
 
-    Field field = (Field) doc.getField(DocHelper.TEXT_FIELD_2_KEY);
+    IndexableField field = doc.getField(DocHelper.TEXT_FIELD_2_KEY);
     assertTrue(field != null);
     assertTrue(field.fieldType().storeTermVectors());
 
     assertFalse(field.fieldType().omitNorms());
     assertEquals(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, field.fieldType().indexOptions());
 
-    field = (Field) doc.getField(DocHelper.TEXT_FIELD_3_KEY);
+    field = doc.getField(DocHelper.TEXT_FIELD_3_KEY);
     assertTrue(field != null);
     assertFalse(field.fieldType().storeTermVectors());
     assertTrue(field.fieldType().omitNorms());
     assertEquals(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, field.fieldType().indexOptions());
 
-    field = (Field) doc.getField(DocHelper.NO_TF_KEY);
+    field = doc.getField(DocHelper.NO_TF_KEY);
     assertTrue(field != null);
     assertFalse(field.fieldType().storeTermVectors());
     assertFalse(field.fieldType().omitNorms());
     assertTrue(field.fieldType().indexOptions() == IndexOptions.DOCS_ONLY);
 
-    DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(DocHelper.TEXT_FIELD_3_KEY);
+    FieldTypes fieldTypes = FieldTypes.getFieldTypes(dir, null);
+    Document2StoredFieldVisitor visitor = new Document2StoredFieldVisitor(fieldTypes, DocHelper.TEXT_FIELD_3_KEY);
     reader.document(0, visitor);
-    final List<StorableField> fields = visitor.getDocument().getFields();
+    final List<IndexableField> fields = visitor.getDocument().getFields();
     assertEquals(1, fields.size());
     assertEquals(DocHelper.TEXT_FIELD_3_KEY, fields.get(0).name());
     reader.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java Sat Nov  1 08:39:27 2014
@@ -44,6 +44,7 @@ import org.apache.lucene.analysis.tokena
 import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
 import org.apache.lucene.document.BinaryDocValuesField;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
@@ -1287,8 +1288,8 @@ public class TestIndexWriter extends Luc
     w.close();
 
     IndexReader ir = DirectoryReader.open(dir);
-    StoredDocument doc2 = ir.document(0);
-    StorableField f3 = doc2.getField("binary");
+    Document2 doc2 = ir.document(0);
+    IndexableField f3 = doc2.getField("binary");
     b = f3.binaryValue().bytes;
     assertTrue(b != null);
     assertEquals(17, b.length, 17);
@@ -2111,17 +2112,7 @@ public class TestIndexWriter extends Luc
     }
     // add broken doc
     try {
-      iw.addDocument(new IndexDocument() {
-        @Override
-        public Iterable<IndexableField> indexableFields() {
-          return null;
-        }
-        
-        @Override
-        public Iterable<StorableField> storableFields() {
-          return Collections.emptyList();
-        }
-      });
+      iw.addDocument(null);
       fail();
     } catch (NullPointerException expected) {}
     // ensure good docs are still ok
@@ -2132,37 +2123,6 @@ public class TestIndexWriter extends Luc
     dir.close();
   }
   
-  public void testNullIterable2() throws IOException {
-    Directory dir = newDirectory();
-    RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
-    // add 3 good docs
-    for (int i = 0; i < 3; i++) {
-      Document doc = new Document();
-      doc.add(new StringField("id", Integer.toString(i), Field.Store.NO));
-      iw.addDocument(doc);
-    }
-    // add broken doc
-    try {
-      iw.addDocument(new IndexDocument() {
-        @Override
-        public Iterable<IndexableField> indexableFields() {
-          return Collections.emptyList();
-        }
-        
-        @Override
-        public Iterable<StorableField> storableFields() {
-          return null;
-        }
-      });
-    } catch (NullPointerException expected) {}
-    // ensure good docs are still ok
-    IndexReader ir = iw.getReader();
-    assertEquals(3, ir.numDocs());
-    ir.close();
-    iw.close();
-    dir.close();
-  }
-  
   public void testIterableFieldThrowsException() throws IOException {
     Directory dir = newDirectory();
     IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
@@ -2174,27 +2134,16 @@ public class TestIndexWriter extends Luc
       int numDocs = atLeast(4);
       for (int j = 0; j < numDocs; j++) {
         String id = Integer.toString(docId++);
-        final List<StorableField> storedFields = new ArrayList<>();
-        storedFields.add(new StoredField("id", id));
-        storedFields.add(new StoredField("foo",TestUtil.randomSimpleString(random())));
         final List<IndexableField> indexFields = new ArrayList<>();
         indexFields.add(new StringField("id", id, Field.Store.NO));
         indexFields.add(new StringField("foo", TestUtil.randomSimpleString(random()), Field.Store.NO));
+        indexFields.add(new StoredField("id", id));
+        indexFields.add(new StoredField("foo",TestUtil.randomSimpleString(random())));
         docId++;
         
         boolean success = false;
         try {
-          w.addDocument(new IndexDocument() {
-            @Override
-            public Iterable<IndexableField> indexableFields() {
-              return new RandomFailingIterable<IndexableField>(indexFields, random());
-            }
-
-            @Override
-            public Iterable<StorableField> storableFields() {
-              return new RandomFailingIterable<StorableField>(storedFields, random());
-            }        
-          });
+          w.addDocument(new RandomFailingIterable<IndexableField>(indexFields, random()));
           success = true;
         } catch (RuntimeException e) {
           assertEquals("boom", e.getMessage());
@@ -2232,7 +2181,7 @@ public class TestIndexWriter extends Luc
     int docId = 0;
     Set<String> liveIds = new HashSet<>();
     for (int i = 0; i < iters; i++) {
-      List<Document> docs = new ArrayList<>();
+      List<Iterable<IndexableField>> docs = new ArrayList<>();
       FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
       FieldType idFt = new FieldType(TextField.TYPE_STORED);
       
@@ -2245,15 +2194,15 @@ public class TestIndexWriter extends Luc
       }
       boolean success = false;
       try {
-        w.addDocuments(new RandomFailingIterable<IndexDocument>(docs, random()));
+        w.addDocuments(new RandomFailingIterable<Iterable<IndexableField>>(docs, random()));
         success = true;
       } catch (RuntimeException e) {
         assertEquals("boom", e.getMessage());
       } finally {
         if (success) {
           docCount += docs.size();
-          for (Document indexDocument : docs) {
-            liveIds.add(indexDocument.get("id"));  
+          for (Iterable<IndexableField> indexDocument : docs) {
+            liveIds.add(((Document) indexDocument).get("id"));  
           }
         }
       }

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Sat Nov  1 08:39:27 2014
@@ -1759,15 +1759,13 @@ public class TestIndexWriterExceptions e
     doc.add(new StringField("foo", "bar", Field.Store.NO));
     iw.addDocument(doc); // add an 'ok' document
     try {
-      doc = new Document();
       // try to boost with norms omitted
-      IndexDocument docList = new IndexDocument() {
+      Iterable<IndexableField> doc2 = new Iterable<IndexableField>() {
         
         List<IndexableField> list = new ArrayList<>();
-        List<StorableField> storedList = new ArrayList<>();
         
         @Override
-        public Iterable<IndexableField> indexableFields() {
+        public Iterator<IndexableField> iterator() {
           if (list.size() == 0) {
             list.add(new IndexableField() {
               @Override
@@ -1786,21 +1784,40 @@ public class TestIndexWriterExceptions e
               }
 
               @Override
+              public String stringValue() {
+                return null;
+              }
+
+              @Override
+              public Number numericDocValue() {
+                return null;
+              }
+
+              @Override
+              public Number numericValue() {
+                return null;
+              }
+
+              @Override
+              public BytesRef binaryDocValue() {
+                return null;
+              }
+
+              @Override
+              public BytesRef binaryValue() {
+                return null;
+              }
+
+              @Override
               public TokenStream tokenStream(Analyzer analyzer, TokenStream previous) throws IOException {
                 return null;
               }
             });
           }
-          return list;
-        }
-
-        @Override
-        public Iterable<StorableField> storableFields() {
-          return storedList;
+          return list.iterator();
         }
-        
       };
-      iw.addDocument(docList);
+      iw.addDocument(doc2);
       fail("didn't get any exception, boost silently discarded");
     } catch (UnsupportedOperationException expected) {
       // expected

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java Sat Nov  1 08:39:27 2014
@@ -20,6 +20,7 @@ import java.util.Random;
 import java.util.concurrent.atomic.AtomicReference;
 
 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;
@@ -85,7 +86,7 @@ public class TestIndexWriterMerging exte
     int max = reader.maxDoc();
     for (int i = 0; i < max; i++)
     {
-      StoredDocument temp = reader.document(i);
+      Document2 temp = reader.document(i);
       //System.out.println("doc "+i+"="+temp.getField("count").stringValue());
       //compare the index doc number to the value that it should be
       if (!temp.getField("count").stringValue().equals((i + startAt) + ""))

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java Sat Nov  1 08:39:27 2014
@@ -267,10 +267,10 @@ public class TestIndexWriterReader exten
     assertEquals(100, index2df);
 
     // verify the docs are from different indexes
-    StoredDocument doc5 = r1.document(5);
-    assertEquals("index1", doc5.get("indexname"));
-    StoredDocument doc150 = r1.document(150);
-    assertEquals("index2", doc150.get("indexname"));
+    Document2 doc5 = r1.document(5);
+    assertEquals("index1", doc5.getString("indexname"));
+    Document2 doc150 = r1.document(150);
+    assertEquals("index2", doc150.getString("indexname"));
     r1.close();
     writer.close();
     dir1.close();

Modified: lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterThreadsToSegments.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterThreadsToSegments.java?rev=1635898&r1=1635897&r2=1635898&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterThreadsToSegments.java (original)
+++ lucene/dev/branches/lucene6005/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterThreadsToSegments.java Sat Nov  1 08:39:27 2014
@@ -30,6 +30,7 @@ import org.apache.lucene.analysis.MockAn
 import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
@@ -337,7 +338,8 @@ public class TestIndexWriterThreadsToSeg
             SegmentInfo si = TestUtil.getDefaultCodec().segmentInfoFormat().read(dir, segName, id, IOContext.DEFAULT);
             si.setCodec(codec);
             SegmentCommitInfo sci = new SegmentCommitInfo(si, 0, -1, -1, -1);
-            SegmentReader sr = new SegmentReader(sci, IOContext.DEFAULT);
+            SegmentReader sr = new SegmentReader(w.getFieldTypes(),
+                                                 sci, IOContext.DEFAULT);
             try {
               thread0Count += sr.docFreq(new Term("field", "threadID0"));
               thread1Count += sr.docFreq(new Term("field", "threadID1"));



Mime
View raw message