Apache Lucene open-source search software
LUCENE-6271: fix MultiPhraseQuery's positions check
Robert Muir198ec5516b0a
diff --git a/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java b/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.javaindex 5a34ec26600..0a1e8e7e0d6 100644--- a/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java+++ b/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java@@ -190,6 +190,11 @@ public class MultiPhraseQuery extends Query {return null;}+ // TODO: move this check to createWeight to happen earlier to the user?+ if (!fieldTerms.hasPositions()) {+ throw new IllegalStateException("field \"" + field + "\" was indexed without position data; cannot run PhraseQuery (phrase=" + getQuery() + ")");+ }+// Reuse single TermsEnum below:final TermsEnum termsEnum = fieldTerms.iterator(null);@@ -230,13 +235,6 @@ public class MultiPhraseQuery extends Query {termsEnum.seekExact(term.bytes(), termState);postingsEnum = termsEnum.postings(liveDocs, null, PostingsEnum.POSITIONS);- // nocommit: check- 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();}