You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rj...@apache.org on 2015/03/31 20:01:44 UTC
svn commit: r1670413 - in
/lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search:
MultiPhraseQuery.java PhraseQuery.java spans/SpanTermQuery.java
Author: rjernst
Date: Tue Mar 31 18:01:44 2015
New Revision: 1670413
URL: http://svn.apache.org/r1670413
Log:
LUCENE-6271: more nocommit removals for phrase/span term
Modified:
lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java
lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
Modified: lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=1670413&r1=1670412&r2=1670413&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java Tue Mar 31 18:01:44 2015
@@ -191,7 +191,7 @@ public class MultiPhraseQuery extends Qu
}
// 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 Postings
}
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);
}
Modified: lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java?rev=1670413&r1=1670412&r2=1670413&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java Tue Mar 31 18:01:44 2015
@@ -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);
}
Modified: lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java?rev=1670413&r1=1670412&r2=1670413&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (original)
+++ lucene/dev/branches/lucene6271/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java Tue Mar 31 18:01:44 2015
@@ -94,6 +94,10 @@ public class SpanTermQuery extends SpanQ
// 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 SpanQ
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);
}
}