LUCENE-6271: fix MultiPhraseQuery's positions check

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene6271@1670368 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2015-03-31 15:52:33 +00:00
parent 05cf3fde0d
commit 198ec5516b
1 changed files with 5 additions and 7 deletions

View File

@ -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();
}