LUCENE-6271: more nocommit removals for phrase/span term

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene6271@1670413 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan Ernst 2015-03-31 18:01:44 +00:00
parent 19e32583a7
commit 6cf7a55131
3 changed files with 10 additions and 23 deletions

View File

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

View File

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

View File

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