You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2015/04/04 03:56:47 UTC

svn commit: r1671239 [1/5] - in /lucene/dev/branches/lucene_solr_5_1: ./ dev-tools/ lucene/ lucene/analysis/ lucene/backward-codecs/ lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/ lucene/backward-codecs/src/java/org/apache/lucene/c...

Author: rmuir
Date: Sat Apr  4 01:56:45 2015
New Revision: 1671239

URL: http://svn.apache.org/r1671239
Log:
LUCENE-6271: PostingsEnum should have consistent flags behavior

Removed:
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/test/org/apache/lucene/index/TestLegacyPostings.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/test/org/apache/lucene/index/TestPostingsEnum.java
Modified:
    lucene/dev/branches/lucene_solr_5_1/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/dev-tools/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/BUILD.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/JRE_VERSION_MIGRATION.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/LICENSE.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/MIGRATE.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/NOTICE.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/README.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/SYSTEM_REQUIREMENTS.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/analysis/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40IntersectTermsEnum.java
    lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40SegmentTermsEnum.java
    lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene42/Lucene42TermVectorsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene41/TestLucene41PostingsFormat3.java
    lucene/dev/branches/lucene_solr_5_1/lucene/benchmark/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/build.xml   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/classification/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/codecs/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blockterms/BlockTermsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsIntersectTermsEnum.java
    lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsSegmentTermsEnum.java
    lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
    lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
    lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/common-build.xml   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/core/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/DocsAndPositionsEnum.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/LeafReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiTermsEnum.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/test/org/apache/lucene/index/TestFilterLeafReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java
    lucene/dev/branches/lucene_solr_5_1/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/demo/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/expressions/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/facet/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/grouping/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/highlighter/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/highlighter/src/java/org/apache/lucene/search/postingshighlight/PostingsHighlighter.java
    lucene/dev/branches/lucene_solr_5_1/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java
    lucene/dev/branches/lucene_solr_5_1/lucene/ivy-ignore-conflicts.properties   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/ivy-settings.xml   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/ivy-versions.properties   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/join/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/licenses/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/memory/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/misc/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/misc/src/java/org/apache/lucene/index/SortingLeafReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/module-build.xml   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/queries/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/queryparser/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/replicator/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/sandbox/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/site/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/spatial/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/suggest/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/test-framework/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/test-framework/src/java/org/apache/lucene/index/AssertingLeafReader.java
    lucene/dev/branches/lucene_solr_5_1/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
    lucene/dev/branches/lucene_solr_5_1/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java
    lucene/dev/branches/lucene_solr_5_1/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/branches/lucene_solr_5_1/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
    lucene/dev/branches/lucene_solr_5_1/lucene/tools/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/lucene/version.properties   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/CHANGES.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/LICENSE.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/NOTICE.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/README.txt   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/bin/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/build.xml   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/cloud-dev/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/common-build.xml   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/contrib/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
    lucene/dev/branches/lucene_solr_5_1/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
    lucene/dev/branches/lucene_solr_5_1/solr/example/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/licenses/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/scripts/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/server/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/site/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/site/SYSTEM_REQUIREMENTS.mdtext   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/solrj/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/test-framework/   (props changed)
    lucene/dev/branches/lucene_solr_5_1/solr/webapp/   (props changed)

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/CHANGES.txt?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/CHANGES.txt Sat Apr  4 01:56:45 2015
@@ -139,7 +139,7 @@ API Changes
 * LUCENE-6218, LUCENE-6220: Add Collector.needsScores() and needsScores
   parameter to Query.createWeight(). (Robert Muir, Adrien Grand)
 
-* LUCENE-4524, LUCENE-6246, LUCENE-6256: Merge DocsEnum and DocsAndPositionsEnum
+* LUCENE-4524, LUCENE-6246, LUCENE-6256, LUCENE-6271: Merge DocsEnum and DocsAndPositionsEnum
   into a single PostingsEnum iterator.  TermsEnum.docs() and TermsEnum.docsAndPositions()
   are replaced by TermsEnum.postings(). 
   (Alan Woodward, Simon Willnauer, Robert Muir, Ryan Ernst)

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40IntersectTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40IntersectTermsEnum.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40IntersectTermsEnum.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40IntersectTermsEnum.java Sat Apr  4 01:56:45 2015
@@ -19,6 +19,7 @@ package org.apache.lucene.codecs.blocktr
 
 import java.io.IOException;
 
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.TermState;
@@ -208,7 +209,7 @@ final class Lucene40IntersectTermsEnum e
 
   @Override
   public PostingsEnum postings(Bits skipDocs, PostingsEnum reuse, int flags) throws IOException {
-    if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) && fr.fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
+    if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS) && fr.fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
       // Positions were not indexed:
       return null;
     }

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40SegmentTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40SegmentTermsEnum.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40SegmentTermsEnum.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/blocktree/Lucene40SegmentTermsEnum.java Sat Apr  4 01:56:45 2015
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.PrintStream;
 
 import org.apache.lucene.codecs.BlockTermState;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.TermState;
@@ -986,7 +987,7 @@ final class Lucene40SegmentTermsEnum ext
   @Override
   public PostingsEnum postings(Bits skipDocs, PostingsEnum reuse, int flags) throws IOException {
 
-    if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) && fr.fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
+    if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS) && fr.fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
       // Positions were not indexed:
       return null;
     }

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java Sat Apr  4 01:56:45 2015
@@ -197,8 +197,8 @@ final class Lucene40PostingsReader exten
     
   @Override
   public PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
-
-    if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
+    boolean hasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
+    if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) && hasPositions) {
       return fullPostings(fieldInfo, termState, liveDocs, reuse, flags);
     }
 

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsReader.java Sat Apr  4 01:56:45 2015
@@ -29,6 +29,7 @@ import java.util.NoSuchElementException;
 import org.apache.lucene.codecs.CodecUtil;
 import org.apache.lucene.codecs.TermVectorsReader;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfos;
 import org.apache.lucene.index.Fields;
@@ -492,18 +493,18 @@ final class Lucene40TermVectorsReader ex
     public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
 
       if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
-        if (!storePositions && !storeOffsets) {
+        if (storePositions || storeOffsets) {
+          TVPostingsEnum docsAndPositionsEnum;
+          if (reuse != null && reuse instanceof TVPostingsEnum) {
+            docsAndPositionsEnum = (TVPostingsEnum) reuse;
+          } else {
+            docsAndPositionsEnum = new TVPostingsEnum();
+          }
+          docsAndPositionsEnum.reset(liveDocs, positions, startOffsets, endOffsets, payloadOffsets, payloadData);
+          return docsAndPositionsEnum;
+        } else if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
           return null;
         }
-
-        TVPostingsEnum docsAndPositionsEnum;
-        if (reuse != null && reuse instanceof TVPostingsEnum) {
-          docsAndPositionsEnum = (TVPostingsEnum) reuse;
-        } else {
-          docsAndPositionsEnum = new TVPostingsEnum();
-        }
-        docsAndPositionsEnum.reset(liveDocs, positions, startOffsets, endOffsets, payloadOffsets, payloadData);
-        return docsAndPositionsEnum;
       }
 
       TVDocsEnum docsEnum;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java Sat Apr  4 01:56:45 2015
@@ -244,8 +244,8 @@ public final class Lucene41PostingsReade
     
   @Override
   public PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
-
-    if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS))
+    boolean hasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
+    if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) && hasPositions)
       return fullPostings(fieldInfo, termState, liveDocs, reuse, flags);
 
     BlockDocsEnum docsEnum;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene42/Lucene42TermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene42/Lucene42TermVectorsReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene42/Lucene42TermVectorsReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene42/Lucene42TermVectorsReader.java Sat Apr  4 01:56:45 2015
@@ -30,6 +30,7 @@ import org.apache.lucene.codecs.compress
 import org.apache.lucene.codecs.compressing.Decompressor;
 import org.apache.lucene.codecs.lucene41.Lucene41StoredFieldsIndexReader;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfos;
 import org.apache.lucene.index.Fields;
@@ -885,7 +886,7 @@ final class Lucene42TermVectorsReader ex
     @Override
     public final PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
 
-      if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
+      if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
         if (positions == null && startOffsets == null) {
           return null;
         }

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene41/TestLucene41PostingsFormat3.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene41/TestLucene41PostingsFormat3.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene41/TestLucene41PostingsFormat3.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene41/TestLucene41PostingsFormat3.java Sat Apr  4 01:56:45 2015
@@ -171,9 +171,10 @@ public class TestLucene41PostingsFormat3
     
     // NOTE: we don't assert hasOffsets/hasPositions/hasPayloads because they are allowed to be different
 
+    boolean bothHavePositions = leftTerms.hasPositions() && rightTerms.hasPositions();
     TermsEnum leftTermsEnum = leftTerms.iterator(null);
     TermsEnum rightTermsEnum = rightTerms.iterator(null);
-    assertTermsEnum(leftTermsEnum, rightTermsEnum, true);
+    assertTermsEnum(leftTermsEnum, rightTermsEnum, true, bothHavePositions);
     
     assertTermsSeeking(leftTerms, rightTerms);
     
@@ -186,7 +187,7 @@ public class TestLucene41PostingsFormat3
           // TODO: test start term too
           TermsEnum leftIntersection = leftTerms.intersect(automaton, null);
           TermsEnum rightIntersection = rightTerms.intersect(automaton, null);
-          assertTermsEnum(leftIntersection, rightIntersection, rarely());
+          assertTermsEnum(leftIntersection, rightIntersection, rarely(), bothHavePositions);
         }
       }
     }
@@ -279,7 +280,7 @@ public class TestLucene41PostingsFormat3
    * checks the terms enum sequentially
    * if deep is false, it does a 'shallow' test that doesnt go down to the docsenums
    */
-  public void assertTermsEnum(TermsEnum leftTermsEnum, TermsEnum rightTermsEnum, boolean deep) throws Exception {
+  public void assertTermsEnum(TermsEnum leftTermsEnum, TermsEnum rightTermsEnum, boolean deep, boolean hasPositions) throws Exception {
     BytesRef term;
     Bits randomBits = new RandomBits(MAXDOC, random().nextDouble(), random());
     PostingsEnum leftPositions = null;
@@ -291,56 +292,58 @@ public class TestLucene41PostingsFormat3
       assertEquals(term, rightTermsEnum.next());
       assertTermStats(leftTermsEnum, rightTermsEnum);
       if (deep) {
-        // with payloads + off
-        assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.ALL),
-                                   rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.ALL));
-        assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.ALL),
-                                   rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.ALL));
-
-        assertPositionsSkipping(leftTermsEnum.docFreq(), 
-                                leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.POSITIONS),
-                                rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.POSITIONS));
-        assertPositionsSkipping(leftTermsEnum.docFreq(), 
-                                leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.POSITIONS),
-                                rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.POSITIONS));
-        // with payloads only
-        assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.PAYLOADS),
-                                   rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.PAYLOADS));
-        assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.PAYLOADS),
-                                   rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.PAYLOADS));
-
-        assertPositionsSkipping(leftTermsEnum.docFreq(), 
-                                leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.PAYLOADS),
-                                rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.PAYLOADS));
-        assertPositionsSkipping(leftTermsEnum.docFreq(), 
-                                leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.PAYLOADS),
-                                rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.PAYLOADS));
-
-        // with offsets only
-        assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.OFFSETS),
-                                   rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.OFFSETS));
-        assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.OFFSETS),
-                                   rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.OFFSETS));
-
-        assertPositionsSkipping(leftTermsEnum.docFreq(), 
-                                leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.OFFSETS),
-                                rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.OFFSETS));
-        assertPositionsSkipping(leftTermsEnum.docFreq(), 
-                                leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.OFFSETS),
-                                rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.OFFSETS));
-        
-        // with positions only
-        assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.POSITIONS),
-                                   rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.POSITIONS));
-        assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.POSITIONS),
-                                   rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.POSITIONS));
-
-        assertPositionsSkipping(leftTermsEnum.docFreq(), 
-                                leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.POSITIONS),
-                                rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.POSITIONS));
-        assertPositionsSkipping(leftTermsEnum.docFreq(), 
-                                leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.POSITIONS),
-                                rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.POSITIONS));
+        if (hasPositions) {
+          // with payloads + off
+          assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.ALL),
+              rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.ALL));
+          assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.ALL),
+              rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.ALL));
+          
+          assertPositionsSkipping(leftTermsEnum.docFreq(), 
+              leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.POSITIONS),
+              rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.POSITIONS));
+          assertPositionsSkipping(leftTermsEnum.docFreq(), 
+              leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.POSITIONS),
+              rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.POSITIONS));
+          // with payloads only
+          assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.PAYLOADS),
+              rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.PAYLOADS));
+          assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.PAYLOADS),
+              rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.PAYLOADS));
+          
+          assertPositionsSkipping(leftTermsEnum.docFreq(), 
+              leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.PAYLOADS),
+              rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.PAYLOADS));
+          assertPositionsSkipping(leftTermsEnum.docFreq(), 
+              leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.PAYLOADS),
+              rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.PAYLOADS));
+          
+          // with offsets only
+          assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.OFFSETS),
+              rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.OFFSETS));
+          assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.OFFSETS),
+              rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.OFFSETS));
+          
+          assertPositionsSkipping(leftTermsEnum.docFreq(), 
+              leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.OFFSETS),
+              rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.OFFSETS));
+          assertPositionsSkipping(leftTermsEnum.docFreq(), 
+              leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.OFFSETS),
+              rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.OFFSETS));
+          
+          // with positions only
+          assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.POSITIONS),
+              rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.POSITIONS));
+          assertDocsAndPositionsEnum(leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.POSITIONS),
+              rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.POSITIONS));
+          
+          assertPositionsSkipping(leftTermsEnum.docFreq(), 
+              leftPositions = leftTermsEnum.postings(null, leftPositions, PostingsEnum.POSITIONS),
+              rightPositions = rightTermsEnum.postings(null, rightPositions, PostingsEnum.POSITIONS));
+          assertPositionsSkipping(leftTermsEnum.docFreq(), 
+              leftPositions = leftTermsEnum.postings(randomBits, leftPositions, PostingsEnum.POSITIONS),
+              rightPositions = rightTermsEnum.postings(randomBits, rightPositions, PostingsEnum.POSITIONS));
+        }
         
         // with freqs:
         assertDocsEnum(leftDocs = leftTermsEnum.postings(null, leftDocs),
@@ -388,11 +391,6 @@ public class TestLucene41PostingsFormat3
    * checks docs + freqs + positions + payloads, sequentially
    */
   public void assertDocsAndPositionsEnum(PostingsEnum leftDocs, PostingsEnum rightDocs) throws Exception {
-    if (leftDocs == null || rightDocs == null) {
-      assertNull(leftDocs);
-      assertNull(rightDocs);
-      return;
-    }
     assertEquals(-1, leftDocs.docID());
     assertEquals(-1, rightDocs.docID());
     int docid;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blockterms/BlockTermsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blockterms/BlockTermsReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blockterms/BlockTermsReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blockterms/BlockTermsReader.java Sat Apr  4 01:56:45 2015
@@ -30,6 +30,7 @@ import org.apache.lucene.codecs.CodecUti
 import org.apache.lucene.codecs.FieldsProducer;
 import org.apache.lucene.codecs.PostingsReaderBase;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.IndexFileNames;
@@ -657,8 +658,8 @@ public class BlockTermsReader extends Fi
 
       @Override
       public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
-
-        if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
+        
+        if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
           if (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
             // Positions were not indexed:
             return null;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsIntersectTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsIntersectTermsEnum.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsIntersectTermsEnum.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsIntersectTermsEnum.java Sat Apr  4 01:56:45 2015
@@ -20,6 +20,7 @@ package org.apache.lucene.codecs.blocktr
 import java.io.IOException;
 
 import org.apache.lucene.codecs.blocktreeords.FSTOrdsOutputs.Output;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.TermState;
@@ -203,8 +204,8 @@ final class OrdsIntersectTermsEnum exten
 
   @Override
   public PostingsEnum postings(Bits skipDocs, PostingsEnum reuse, int flags) throws IOException {
-
-    if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
+    
+    if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
       if (fr.fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
         // Positions were not indexed:
         return null;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsSegmentTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsSegmentTermsEnum.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsSegmentTermsEnum.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsSegmentTermsEnum.java Sat Apr  4 01:56:45 2015
@@ -25,6 +25,7 @@ import java.io.PrintStream;
 
 import org.apache.lucene.codecs.BlockTermState;
 import org.apache.lucene.codecs.blocktreeords.FSTOrdsOutputs.Output;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.TermState;
@@ -925,7 +926,7 @@ public final class OrdsSegmentTermsEnum
   @Override
   public PostingsEnum postings(Bits skipDocs, PostingsEnum reuse, int flags) throws IOException {
 
-    if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
+    if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
       if (fr.fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
         // Positions were not indexed:
         return null;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java Sat Apr  4 01:56:45 2015
@@ -28,6 +28,7 @@ import org.apache.lucene.codecs.FieldsCo
 import org.apache.lucene.codecs.FieldsProducer;
 import org.apache.lucene.codecs.PostingsFormat;
 import org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.Fields;
 import org.apache.lucene.index.IndexOptions;
@@ -872,22 +873,58 @@ public final class DirectPostingsFormat
 
       @Override
       public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
+        
+        if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
+          if (!hasPos) {
+            // Positions were not indexed:
+            return null;
+          }
+        }
+
         // TODO: implement reuse
         // it's hairy!
 
+        // TODO: the logic of which enum impl to choose should be refactored to be simpler...
         if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
-          if (!hasPos) {
-            return null;
-          }
 
           if (terms[termOrd] instanceof LowFreqTerm) {
             final LowFreqTerm term = ((LowFreqTerm) terms[termOrd]);
             final int[] postings = term.postings;
+            if (hasFreq == false) {
+              LowFreqDocsEnumNoTF docsEnum;
+              if (reuse instanceof LowFreqDocsEnumNoTF) {
+                docsEnum = (LowFreqDocsEnumNoTF) reuse;
+                if (!docsEnum.canReuse(liveDocs)) {
+                  docsEnum = new LowFreqDocsEnumNoTF(liveDocs);
+                }
+              } else {
+                docsEnum = new LowFreqDocsEnumNoTF(liveDocs);
+              }
+
+              return docsEnum.reset(postings);
+              
+            } else if (hasPos == false) {
+              LowFreqDocsEnumNoPos docsEnum;
+              if (reuse instanceof LowFreqDocsEnumNoPos) {
+                docsEnum = (LowFreqDocsEnumNoPos) reuse;
+                if (!docsEnum.canReuse(liveDocs)) {
+                  docsEnum = new LowFreqDocsEnumNoPos(liveDocs);
+                }
+              } else {
+                docsEnum = new LowFreqDocsEnumNoPos(liveDocs);
+              }
+
+              return docsEnum.reset(postings);
+            }
             final byte[] payloads = term.payloads;
             return new LowFreqPostingsEnum(liveDocs, hasOffsets, hasPayloads).reset(postings, payloads);
           } else {
             final HighFreqTerm term = (HighFreqTerm) terms[termOrd];
-            return new HighFreqPostingsEnum(liveDocs, hasOffsets).reset(term.docIDs, term.freqs, term.positions, term.payloads);
+            if (hasPos == false) {
+              return new HighFreqDocsEnum(liveDocs).reset(term.docIDs, term.freqs);
+            } else {
+              return new HighFreqPostingsEnum(liveDocs, hasOffsets).reset(term.docIDs, term.freqs, term.positions, term.payloads);
+            }
           }
         }
 
@@ -1467,12 +1504,19 @@ public final class DirectPostingsFormat
 
       @Override
       public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) {
-        // TODO: implement reuse
-        // it's hairy!
-        if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
+        
+        if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
           if (!hasPos) {
+            // Positions were not indexed:
             return null;
           }
+        }
+        
+        // TODO: implement reuse
+        // it's hairy!
+
+        // TODO: the logic of which enum impl to choose should be refactored to be simpler...
+        if (hasPos && PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
           if (terms[termOrd] instanceof LowFreqTerm) {
             final LowFreqTerm term = ((LowFreqTerm) terms[termOrd]);
             final int[] postings = term.postings;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java Sat Apr  4 01:56:45 2015
@@ -31,6 +31,7 @@ import org.apache.lucene.codecs.FieldsPr
 import org.apache.lucene.codecs.PostingsFormat;
 import org.apache.lucene.codecs.TermStats;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfos;
@@ -828,11 +829,17 @@ public final class MemoryPostingsFormat
     
     @Override
     public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) {
-
-      if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
+      
+      if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
         if (field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
+          // Positions were not indexed:
           return null;
         }
+      }
+
+      // TODO: the logic of which enum impl to choose should be refactored to be simpler...
+      boolean hasPositions = field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
+      if (hasPositions && PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
         boolean hasOffsets = field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
         decodeMetaData();
         FSTPostingsEnum docsAndPositionsEnum;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java Sat Apr  4 01:56:45 2015
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.TreeMap;
 
 import org.apache.lucene.codecs.FieldsProducer;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfos;
 import org.apache.lucene.index.IndexOptions;
@@ -208,12 +209,16 @@ class SimpleTextFieldsReader extends Fie
 
     @Override
     public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
-
-      if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
+      
+      if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
         if (indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
-          // Positions were not indexed
+          // Positions were not indexed:
           return null;
         }
+      }
+
+      boolean hasPositions = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
+      if (hasPositions && PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
 
         SimpleTextPostingsEnum docsAndPositionsEnum;
         if (reuse != null && reuse instanceof SimpleTextPostingsEnum && ((SimpleTextPostingsEnum) reuse).canReuse(SimpleTextFieldsReader.this.in)) {

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java Sat Apr  4 01:56:45 2015
@@ -26,6 +26,8 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 
 import org.apache.lucene.codecs.TermVectorsReader;
+import org.apache.lucene.index.DocsAndPositionsEnum;
+import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.Fields;
 import org.apache.lucene.index.IndexFileNames;
@@ -390,16 +392,17 @@ public class SimpleTextTermVectorsReader
 
     @Override
     public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
-
+      
       if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
         SimpleTVPostings postings = current.getValue();
-        if (postings.positions == null && postings.startOffsets == null) {
+        if (postings.positions != null || postings.startOffsets != null) {
+          // TODO: reuse
+          SimpleTVPostingsEnum e = new SimpleTVPostingsEnum();
+          e.reset(liveDocs, postings.positions, postings.startOffsets, postings.endOffsets, postings.payloads);
+          return e;
+        } else if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
           return null;
         }
-        // TODO: reuse
-        SimpleTVPostingsEnum e = new SimpleTVPostingsEnum();
-        e.reset(liveDocs, postings.positions, postings.startOffsets, postings.endOffsets, postings.payloads);
-        return e;
       }
 
       // TODO: reuse

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java Sat Apr  4 01:56:45 2015
@@ -27,6 +27,8 @@ import java.util.NoSuchElementException;
 import org.apache.lucene.codecs.CodecUtil;
 import org.apache.lucene.codecs.TermVectorsReader;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocsAndPositionsEnum;
+import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfos;
@@ -936,12 +938,13 @@ public final class CompressingTermVector
 
     @Override
     public final PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
-
-      if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
-        if (positions == null && startOffsets == null)
+      if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
+        if (positions == null && startOffsets == null) {
+          // Positions nor offsets were indexed:
           return null;
+        }
       }
-
+      
       final TVPostingsEnum docsEnum;
       if (reuse != null && reuse instanceof TVPostingsEnum) {
         docsEnum = (TVPostingsEnum) reuse;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java Sat Apr  4 01:56:45 2015
@@ -26,6 +26,7 @@ import org.apache.lucene.codecs.BlockTer
 import org.apache.lucene.codecs.CodecUtil;
 import org.apache.lucene.codecs.PostingsReaderBase;
 import org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.IntBlockTermState;
+import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.IndexOptions;
@@ -196,8 +197,19 @@ public final class Lucene50PostingsReade
     
   @Override
   public PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
+    
+    boolean indexHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
+    boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+    boolean indexHasPayloads = fieldInfo.hasPayloads();
+    
+    if (PostingsEnum.featureRequested(flags, DocsAndPositionsEnum.OLD_NULL_SEMANTICS)) {
+      if (!indexHasPositions) {
+        // Positions were not indexed:
+        return null;
+      }
+    }
 
-    if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) == false) {
+    if (indexHasPositions == false || PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) == false) {
       BlockDocsEnum docsEnum;
       if (reuse instanceof BlockDocsEnum) {
         docsEnum = (BlockDocsEnum) reuse;
@@ -208,17 +220,8 @@ public final class Lucene50PostingsReade
         docsEnum = new BlockDocsEnum(fieldInfo);
       }
       return docsEnum.reset(liveDocs, (IntBlockTermState) termState, flags);
-    }
-
-    boolean indexHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
-    boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
-    boolean indexHasPayloads = fieldInfo.hasPayloads();
-
-    if (!indexHasPositions)
-      return null;
-
-    if ((!indexHasOffsets || PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS) == false) &&
-        (!indexHasPayloads || PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS) == false)) {
+    } else if ((indexHasOffsets == false || PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS) == false) &&
+               (indexHasPayloads == false || PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS) == false)) {
       BlockPostingsEnum docsAndPositionsEnum;
       if (reuse instanceof BlockPostingsEnum) {
         docsAndPositionsEnum = (BlockPostingsEnum) reuse;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java Sat Apr  4 01:56:45 2015
@@ -936,8 +936,7 @@ public class CheckIndex implements Close
     
     final Status.TermIndexStatus status = new Status.TermIndexStatus();
     int computedFieldCount = 0;
-    
-    PostingsEnum docs = null;
+
     PostingsEnum postings = null;
     
     String lastField = null;
@@ -1087,8 +1086,7 @@ public class CheckIndex implements Close
           throw new RuntimeException("docfreq: " + docFreq + " is out of bounds");
         }
         sumDocFreq += docFreq;
-        
-        docs = termsEnum.postings(liveDocs, docs);
+
         postings = termsEnum.postings(liveDocs, postings, PostingsEnum.ALL);
 
         if (hasFreqs == false) {
@@ -1113,18 +1111,11 @@ public class CheckIndex implements Close
           }
         }
         
-        final PostingsEnum docs2;
-        if (postings != null) {
-          docs2 = postings;
-        } else {
-          docs2 = docs;
-        }
-        
         int lastDoc = -1;
         int docCount = 0;
         long totalTermFreq = 0;
         while(true) {
-          final int doc = docs2.nextDoc();
+          final int doc = postings.nextDoc();
           if (doc == DocIdSetIterator.NO_MORE_DOCS) {
             break;
           }
@@ -1132,7 +1123,7 @@ public class CheckIndex implements Close
           visitedDocs.set(doc);
           int freq = -1;
           if (hasFreqs) {
-            freq = docs2.freq();
+            freq = postings.freq();
             if (freq <= 0) {
               throw new RuntimeException("term " + term + ": doc " + doc + ": freq " + freq + " is out of bounds");
             }
@@ -1142,7 +1133,7 @@ public class CheckIndex implements Close
             // When a field didn't index freq, it must
             // consistently "lie" and pretend that freq was
             // 1:
-            if (docs2.freq() != 1) {
+            if (postings.freq() != 1) {
               throw new RuntimeException("term " + term + ": doc " + doc + ": freq " + freq + " != 1 when Terms.hasFreqs() is false");
             }
           }
@@ -1214,20 +1205,20 @@ public class CheckIndex implements Close
         // Re-count if there are deleted docs:
         if (liveDocs != null) {
           if (hasFreqs) {
-            docs = termsEnum.postings(null, docs);
+            postings = termsEnum.postings(null, postings);
             docCount = 0;
             totalTermFreq = 0;
-            while(docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
-              visitedDocs.set(docs.docID());
+            while(postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
+              visitedDocs.set(postings.docID());
               docCount++;
-              totalTermFreq += docs.freq();
+              totalTermFreq += postings.freq();
             }
           } else {
-            docs = termsEnum.postings(null, docs, PostingsEnum.NONE);
+            postings = termsEnum.postings(null, postings, PostingsEnum.NONE);
             docCount = 0;
             totalTermFreq = -1;
-            while(docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
-              visitedDocs.set(docs.docID());
+            while(postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
+              visitedDocs.set(postings.docID());
               docCount++;
             }
           }
@@ -1314,15 +1305,15 @@ public class CheckIndex implements Close
         } else {
           for(int idx=0;idx<7;idx++) {
             final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);
-            docs = termsEnum.postings(liveDocs, docs, PostingsEnum.NONE);
-            final int docID = docs.advance(skipDocID);
+            postings = termsEnum.postings(liveDocs, postings, PostingsEnum.NONE);
+            final int docID = postings.advance(skipDocID);
             if (docID == DocIdSetIterator.NO_MORE_DOCS) {
               break;
             } else {
               if (docID < skipDocID) {
                 throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + ") returned docID=" + docID);
               }
-              final int nextDocID = docs.nextDoc();
+              final int nextDocID = postings.nextDoc();
               if (nextDocID == DocIdSetIterator.NO_MORE_DOCS) {
                 break;
               }
@@ -1427,12 +1418,12 @@ public class CheckIndex implements Close
                 throw new RuntimeException("seek to existing term " + seekTerms[i] + " failed");
               }
               
-              docs = termsEnum.postings(liveDocs, docs, PostingsEnum.NONE);
-              if (docs == null) {
+              postings = termsEnum.postings(liveDocs, postings, PostingsEnum.NONE);
+              if (postings == null) {
                 throw new RuntimeException("null DocsEnum from to existing term " + seekTerms[i]);
               }
-              
-              while(docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
+
+              while (postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
                 totDocCount++;
               }
             }
@@ -1445,12 +1436,12 @@ public class CheckIndex implements Close
               }
               
               totDocFreq += termsEnum.docFreq();
-              docs = termsEnum.postings(null, docs, PostingsEnum.NONE);
-              if (docs == null) {
+              postings = termsEnum.postings(null, postings, PostingsEnum.NONE);
+              if (postings == null) {
                 throw new RuntimeException("null DocsEnum from to existing term " + seekTerms[i]);
               }
               
-              while(docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
+              while(postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
                 totDocCountNoDeletes++;
               }
             }
@@ -1849,12 +1840,11 @@ public class CheckIndex implements Close
         infoStream.print("    test: term vectors........");
       }
 
-      PostingsEnum docs = null;
       PostingsEnum postings = null;
 
       // Only used if crossCheckTermVectors is true:
       PostingsEnum postingsDocs = null;
-      PostingsEnum postingsPostings = null;
+      PostingsEnum postingsDocs2 = null;
 
       final Bits liveDocs = reader.getLiveDocs();
 
@@ -1926,67 +1916,43 @@ public class CheckIndex implements Close
                 final boolean hasProx = terms.hasOffsets() || terms.hasPositions();
                 BytesRef term = null;
                 while ((term = termsEnum.next()) != null) {
-                  
-                  if (hasProx) {
-                    postings = termsEnum.postings(null, postings, PostingsEnum.ALL);
-                    assert postings != null;
-                    docs = null;
-                  } else {
-                    docs = termsEnum.postings(null, docs);
-                    assert docs != null;
-                    postings = null;
-                  }
-                  
-                  final PostingsEnum docs2;
-                  if (hasProx) {
-                    assert postings != null;
-                    docs2 = postings;
-                  } else {
-                    assert docs != null;
-                    docs2 = docs;
-                  }
-                  
-                  final PostingsEnum postingsDocs2;
+
+                  // This is the term vectors:
+                  postings = termsEnum.postings(null, postings, PostingsEnum.ALL);
+                  assert postings != null;
+
                   if (!postingsTermsEnum.seekExact(term)) {
                     throw new RuntimeException("vector term=" + term + " field=" + field + " does not exist in postings; doc=" + j);
                   }
-                  postingsPostings = postingsTermsEnum.postings(null, postingsPostings, PostingsEnum.ALL);
-                  if (postingsPostings == null) {
-                    // Term vectors were indexed w/ pos but postings were not
-                    postingsDocs = postingsTermsEnum.postings(null, postingsDocs);
-                    if (postingsDocs == null) {
-                      throw new RuntimeException("vector term=" + term + " field=" + field + " does not exist in postings; doc=" + j);
-                    }
-                  }
-                  
-                  if (postingsPostings != null) {
-                    postingsDocs2 = postingsPostings;
-                  } else {
-                    postingsDocs2 = postingsDocs;
-                  }
+
+                  // This is the inverted index ("real" postings):
+                  postingsDocs2 = postingsTermsEnum.postings(null, postingsDocs2, PostingsEnum.ALL);
+                  assert postingsDocs2 != null;
+
                   
                   final int advanceDoc = postingsDocs2.advance(j);
                   if (advanceDoc != j) {
                     throw new RuntimeException("vector term=" + term + " field=" + field + ": doc=" + j + " was not found in postings (got: " + advanceDoc + ")");
                   }
                   
-                  final int doc = docs2.nextDoc();
+                  final int doc = postings.nextDoc();
                   
                   if (doc != 0) {
                     throw new RuntimeException("vector for doc " + j + " didn't return docID=0: got docID=" + doc);
                   }
                   
                   if (postingsHasFreq) {
-                    final int tf = docs2.freq();
+                    final int tf = postings.freq();
                     if (postingsHasFreq && postingsDocs2.freq() != tf) {
                       throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": freq=" + tf + " differs from postings freq=" + postingsDocs2.freq());
                     }
-                    
+
+                    // Term vectors has prox?
                     if (hasProx) {
                       for (int i = 0; i < tf; i++) {
                         int pos = postings.nextPosition();
-                        if (postingsPostings != null) {
-                          int postingsPos = postingsPostings.nextPosition();
+                        if (postingsTerms.hasPositions()) {
+                          int postingsPos = postingsDocs2.nextPosition();
                           if (terms.hasPositions() && pos != postingsPos) {
                             throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": pos=" + pos + " differs from postings pos=" + postingsPos);
                           }
@@ -2006,19 +1972,18 @@ public class CheckIndex implements Close
                         }
                         lastStartOffset = startOffset;
                          */
-                        
-                        if (postingsPostings != null) {
-                          final int postingsStartOffset = postingsPostings.startOffset();
-                          
-                          final int postingsEndOffset = postingsPostings.endOffset();
-                          if (startOffset != -1 && postingsStartOffset != -1 && startOffset != postingsStartOffset) {
+
+                        if (startOffset != -1 && endOffset != -1 && postingsTerms.hasOffsets()) {
+                          int postingsStartOffset = postingsDocs2.startOffset();
+                          int postingsEndOffset = postingsDocs2.endOffset();
+                          if (startOffset != postingsStartOffset) {
                             throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": startOffset=" + startOffset + " differs from postings startOffset=" + postingsStartOffset);
                           }
-                          if (endOffset != -1 && postingsEndOffset != -1 && endOffset != postingsEndOffset) {
+                          if (endOffset != postingsEndOffset) {
                             throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": endOffset=" + endOffset + " differs from postings endOffset=" + postingsEndOffset);
                           }
                         }
-                        
+
                         BytesRef payload = postings.getPayload();
                         
                         if (payload != null) {
@@ -2026,21 +1991,20 @@ public class CheckIndex implements Close
                         }
                         
                         if (postingsHasPayload && vectorsHasPayload) {
-                          assert postingsPostings != null;
                           
                           if (payload == null) {
                             // we have payloads, but not at this position. 
                             // postings has payloads too, it should not have one at this position
-                            if (postingsPostings.getPayload() != null) {
-                              throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + " has no payload but postings does: " + postingsPostings.getPayload());
+                            if (postingsDocs2.getPayload() != null) {
+                              throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + " has no payload but postings does: " + postingsDocs2.getPayload());
                             }
                           } else {
                             // we have payloads, and one at this position
                             // postings should also have one at this position, with the same bytes.
-                            if (postingsPostings.getPayload() == null) {
+                            if (postingsDocs2.getPayload() == null) {
                               throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + " has payload=" + payload + " but postings does not.");
                             }
-                            BytesRef postingsPayload = postingsPostings.getPayload();
+                            BytesRef postingsPayload = postingsDocs2.getPayload();
                             if (!payload.equals(postingsPayload)) {
                               throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + " has payload=" + payload + " but differs from postings payload=" + postingsPayload);
                             }

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/DocsAndPositionsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/DocsAndPositionsEnum.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/DocsAndPositionsEnum.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/DocsAndPositionsEnum.java Sat Apr  4 01:56:45 2015
@@ -38,6 +38,14 @@ public abstract class DocsAndPositionsEn
   /** Flag to pass to  {@link TermsEnum#docsAndPositions(Bits,DocsAndPositionsEnum,int)}
    *  if you require payloads in the returned enum. */
   public static final int FLAG_PAYLOADS = 0x2;
+  
+  /**
+   * Codec implementations should check for this flag,
+   * and return null when positions are requested but not present.
+   * @deprecated only for internal use.
+   */
+  @Deprecated
+  public static final short OLD_NULL_SEMANTICS = 1 << 14;
 
   /** Sole constructor. (For invocation by subclass 
    * constructors, typically implicit.) */

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java Sat Apr  4 01:56:45 2015
@@ -222,17 +222,17 @@ public class FilterLeafReader extends Le
   }
 
   /** Base class for filtering {@link PostingsEnum} implementations. */
-  public static class FilterDocsEnum extends PostingsEnum {
-    /** The underlying DocsEnum instance. */
+  public static class FilterPostingsEnum extends PostingsEnum {
+    /** The underlying PostingsEnum instance. */
     protected final PostingsEnum in;
 
     /**
-     * Create a new FilterDocsEnum
-     * @param in the underlying DocsEnum instance.
+     * Create a new FilterPostingsEnum
+     * @param in the underlying PostingsEnum instance.
      */
-    public FilterDocsEnum(PostingsEnum in) {
+    public FilterPostingsEnum(PostingsEnum in) {
       if (in == null) {
-        throw new NullPointerException("incoming DocsEnum cannot be null");
+        throw new NullPointerException("incoming PostingsEnum cannot be null");
       }
       this.in = in;
     }

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/LeafReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/LeafReader.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/LeafReader.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/LeafReader.java Sat Apr  4 01:56:45 2015
@@ -223,7 +223,14 @@ public abstract class LeafReader extends
   }
 
   /** Returns {@link PostingsEnum} for the specified term
-   *  with {@link PostingsEnum#FREQS}. */
+   *  with {@link PostingsEnum#FREQS}.
+   *  <p>
+   *  Use this method if you only require documents and frequencies,
+   *  and do not need any proximity data.
+   *  This method is equivalent to 
+   *  {@link #postings(Term, int) postings(term, PostingsEnum.FREQS)}
+   *  @see #postings(Term, int)
+   */
   public final PostingsEnum postings(Term term) throws IOException {
     return postings(term, PostingsEnum.FREQS);
   }

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiFields.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiFields.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiFields.java Sat Apr  4 01:56:45 2015
@@ -159,8 +159,7 @@ public final class MultiFields extends F
    *  required.  Some codecs may be able to optimize
    *  their implementation when offsets and/or payloads are not
    *  required. This will return null if the field or term does not
-   *  exist or positions were not indexed. See {@link
-   *  TermsEnum#postings(Bits, PostingsEnum,int)}. */
+   *  exist. See {@link TermsEnum#postings(Bits, PostingsEnum,int)}. */
   public static PostingsEnum getTermPositionsEnum(IndexReader r, Bits liveDocs, String field, BytesRef term, int flags) throws IOException {
     assert field != null;
     assert term != null;

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiTermsEnum.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiTermsEnum.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/MultiTermsEnum.java Sat Apr  4 01:56:45 2015
@@ -379,22 +379,14 @@ public final class MultiTermsEnum extend
 
       assert entry.index < docsEnum.subPostingsEnums.length: entry.index + " vs " + docsEnum.subPostingsEnums.length + "; " + subs.length;
       final PostingsEnum subPostingsEnum = entry.terms.postings(b, docsEnum.subPostingsEnums[entry.index], flags);
-      if (subPostingsEnum != null) {
-        docsEnum.subPostingsEnums[entry.index] = subPostingsEnum;
-        subDocs[upto].postingsEnum = subPostingsEnum;
-        subDocs[upto].slice = entry.subSlice;
-        upto++;
-      } else {
-        // should this be an error?
-        return null;    // We can't support what is being asked for
-      }
-    }
-
-    if (upto == 0) {
-      return null;
-    } else {
-      return docsEnum.reset(subDocs, upto);
+      assert subPostingsEnum != null;
+      docsEnum.subPostingsEnums[entry.index] = subPostingsEnum;
+      subDocs[upto].postingsEnum = subPostingsEnum;
+      subDocs[upto].slice = entry.subSlice;
+      upto++;
     }
+    
+    return docsEnum.reset(subDocs, upto);
   }
 
   final static class TermsEnumWithSlice {

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java Sat Apr  4 01:56:45 2015
@@ -141,10 +141,17 @@ public abstract class TermsEnum implemen
   /** Get {@link PostingsEnum} for the current term.  Do not
    *  call this when the enum is unpositioned.  This method
    *  will not return null.
+   *  <p>
+   *  Use this method if you only require documents and frequencies,
+   *  and do not need any proximity data.
+   *  This method is equivalent to 
+   *  {@link #postings(Bits, PostingsEnum, int) postings(liveDocs, reuse, PostingsEnum.FREQS)}
    *  
    * @param liveDocs unset bits are documents that should not
    * be returned
-   * @param reuse pass a prior PostingsEnum for possible reuse */
+   * @param reuse pass a prior PostingsEnum for possible reuse 
+   * @see #postings(Bits, PostingsEnum, int)
+   */
   public final PostingsEnum postings(Bits liveDocs, PostingsEnum reuse) throws IOException {
     return postings(liveDocs, reuse, PostingsEnum.FREQS);
   }
@@ -160,7 +167,7 @@ public abstract class TermsEnum implemen
    * @param reuse pass a prior PostingsEnum for possible reuse
    * @param flags specifies which optional per-document values
    *        you require; see {@link PostingsEnum#FREQS}
-   * @see #postings(Bits, PostingsEnum, int) */
+   */
   public abstract PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException;
 
   /**
@@ -334,7 +341,7 @@ public abstract class TermsEnum implemen
       throw new IllegalArgumentException("Invalid legacy docsAndPositions flags: " + flags);
     }
     PostingsEnum actualReuse = DocsAndPositionsEnum.unwrap(reuse);
-    PostingsEnum postings = postings(liveDocs, actualReuse, newFlags);
+    PostingsEnum postings = postings(liveDocs, actualReuse, newFlags | DocsAndPositionsEnum.OLD_NULL_SEMANTICS);
     if (postings == null) {
       return null; // if no positions were indexed
     } else if (postings == actualReuse) {

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java Sat Apr  4 01:56:45 2015
@@ -190,6 +190,11 @@ public class MultiPhraseQuery extends Qu
         return null;
       }
 
+      // TODO: move this check to createWeight to happen earlier to the user?
+      if (fieldTerms.hasPositions() == false) {
+        throw new IllegalStateException("field \"" + field + "\" was indexed without position data; cannot run MultiPhraseQuery (phrase=" + getQuery() + ")");
+      }
+
       // Reuse single TermsEnum below:
       final TermsEnum termsEnum = fieldTerms.iterator(null);
 
@@ -230,12 +235,6 @@ public class MultiPhraseQuery extends Qu
           termsEnum.seekExact(term.bytes(), termState);
           postingsEnum = termsEnum.postings(liveDocs, null, PostingsEnum.POSITIONS);
 
-          if (postingsEnum == null) {
-            // term does exist, but has no positions
-            assert termsEnum.postings(liveDocs, null, PostingsEnum.NONE) != null: "termstate found but no term exists in reader";
-            throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + term.text() + ")");
-          }
-
           docFreq = termsEnum.docFreq();
         }
 
@@ -482,10 +481,6 @@ class UnionPostingsEnum extends Postings
       }
       termsEnum.seekExact(term.bytes(), termState);
       PostingsEnum postings = termsEnum.postings(liveDocs, null, PostingsEnum.POSITIONS);
-      if (postings == null) {
-        // term does exist, but has no positions
-        throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + term.text() + ")");
-      }
       cost += postings.cost();
       postingsEnums.add(postings);
     }

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java Sat Apr  4 01:56:45 2015
@@ -297,6 +297,10 @@ public class PhraseQuery extends Query {
         return null;
       }
 
+      if (fieldTerms.hasPositions() == false) {
+        throw new IllegalStateException("field \"" + field + "\" was indexed without position data; cannot run PhraseQuery (phrase=" + getQuery() + ")");
+      }
+
       // Reuse single TermsEnum below:
       final TermsEnum te = fieldTerms.iterator(null);
       
@@ -309,14 +313,6 @@ public class PhraseQuery extends Query {
         }
         te.seekExact(t.bytes(), state);
         PostingsEnum postingsEnum = te.postings(liveDocs, null, PostingsEnum.POSITIONS);
-
-        // PhraseQuery on a field that did not index
-        // positions.
-        if (postingsEnum == null) {
-          assert te.seekExact(t.bytes()) : "termstate found but no term exists in reader";
-          // term does exist, but has no positions
-          throw new IllegalStateException("field \"" + t.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + t.text() + ")");
-        }
         postingsFreqs[i] = new PostingsAndFreq(postingsEnum, te.docFreq(), positions.get(i), t);
       }
 

Modified: lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java?rev=1671239&r1=1671238&r2=1671239&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (original)
+++ lucene/dev/branches/lucene_solr_5_1/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java Sat Apr  4 01:56:45 2015
@@ -94,6 +94,10 @@ public class SpanTermQuery extends SpanQ
       // so we seek to the term now in this segment..., this sucks because it's ugly mostly!
       final Terms terms = context.reader().terms(term.field());
       if (terms != null) {
+        if (terms.hasPositions() == false) {
+          throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run SpanTermQuery (term=" + term.text() + ")");
+        }
+
         final TermsEnum termsEnum = terms.iterator(null);
         if (termsEnum.seekExact(term.bytes())) { 
           state = termsEnum.termState();
@@ -115,12 +119,6 @@ public class SpanTermQuery extends SpanQ
     termsEnum.seekExact(term.bytes(), state);
     
     final PostingsEnum postings = termsEnum.postings(acceptDocs, null, PostingsEnum.PAYLOADS);
-
-    if (postings != null) {
-      return new TermSpans(postings, term);
-    } else {
-      // term does exist, but has no positions
-      throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run SpanTermQuery (term=" + term.text() + ")");
-    }
+    return new TermSpans(postings, term);
   }
 }