Apache Lucene open-source search software
LUCENE-6271: more nocommit removals for phrase/span term
Ryan Ernst6cf7a55131ca
diff --git a/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java b/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.javaindex 2e2bd6e2d46..fdb75018a95 100644--- a/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java+++ b/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java@@ -191,7 +191,7 @@ public class MultiPhraseQuery extends Query {}// TODO: move this check to createWeight to happen earlier to the user?- if (!fieldTerms.hasPositions()) {+ if (fieldTerms.hasPositions() == false) {throw new IllegalStateException("field \"" + field + "\" was indexed without position data; cannot run MultiPhraseQuery (phrase=" + getQuery() + ")");}@@ -481,11 +481,6 @@ class UnionPostingsEnum extends PostingsEnum {}termsEnum.seekExact(term.bytes(), termState);PostingsEnum postings = termsEnum.postings(liveDocs, null, PostingsEnum.POSITIONS);- // nocommit: check- 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);}diff --git a/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java b/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.javaindex d5d78f774b9..00887acae42 100644--- a/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java+++ b/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java@@ -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,15 +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.- // nocommit: check- 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);}diff --git a/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java b/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.javaindex 5522590f7b9..2dc79ff6377 100644--- a/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java+++ b/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java@@ -94,6 +94,10 @@ public class SpanTermQuery extends SpanQuery {// 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,13 +119,6 @@ public class SpanTermQuery extends SpanQuery {termsEnum.seekExact(term.bytes(), state);final PostingsEnum postings = termsEnum.postings(acceptDocs, null, PostingsEnum.PAYLOADS);-- if (postings != null) {- return new TermSpans(postings, term);- } else {- // nocommit: check- // 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);}}