Apache Lucene open-source search software
LUCENE-6271: merge trunk changes up to r1670529
Robert Muir41ba046a931d
diff --cc lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.javaindex 2dc79ff6377,518f6b7c5f4..caa3963cc41--- 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,12 -94,8 +94,12 @@@ public class SpanTermQuery extends Span// 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())) {+ if (termsEnum.seekExact(term.bytes())) {state = termsEnum.termState();} else {state = null;@@@ -110,15 -106,21 +110,15 @@@} else {state = termContext.get(context.ord);}-+if (state == null) { // term is not present in that reader- return TermSpans.EMPTY_TERM_SPANS;+ return null;}-+final TermsEnum termsEnum = context.reader().terms(term.field()).iterator(null);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);}}