You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2018/04/03 13:57:13 UTC

[1/2] lucene-solr:branch_7x: LUCENE-8196: Check that the TermIntervalsSource is positioned on the correct term

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 62f9c9e77 -> b772b585a
  refs/heads/master 0989e5874 -> 1d6502cec


LUCENE-8196: Check that the TermIntervalsSource is positioned on the correct term


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/b772b585
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/b772b585
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/b772b585

Branch: refs/heads/branch_7x
Commit: b772b585a095b32593e1b99ea7ad110921f3c721
Parents: 62f9c9e
Author: Alan Woodward <ro...@apache.org>
Authored: Tue Apr 3 14:48:19 2018 +0100
Committer: Alan Woodward <ro...@apache.org>
Committed: Tue Apr 3 14:56:57 2018 +0100

----------------------------------------------------------------------
 .../org/apache/lucene/search/intervals/TermIntervalsSource.java | 4 +++-
 .../org/apache/lucene/search/intervals/TestIntervalQuery.java   | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b772b585/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java b/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java
index b375a01..81578ef 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java
@@ -50,7 +50,9 @@ class TermIntervalsSource extends IntervalsSource {
       throw new IllegalArgumentException("Cannot create an IntervalIterator over field " + field + " because it has no indexed positions");
     }
     TermsEnum te = terms.iterator();
-    te.seekExact(term);
+    if (te.seekExact(term) == false) {
+      return null;
+    }
     PostingsEnum pe = te.postings(null, PostingsEnum.POSITIONS);
     float cost = termPositionsCost(te);
     return new IntervalIterator() {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b772b585/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java b/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java
index a81ab76..de7341e 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java
@@ -149,6 +149,11 @@ public class TestIntervalQuery extends LuceneTestCase {
     checkHits(q, new int[]{ 1, 3, 4, 5 });
   }
 
+  public void testNonExistentTerms() throws IOException {
+    Query q = new IntervalQuery(field, Intervals.ordered(Intervals.term("w0"), Intervals.term("w2")));
+    checkHits(q, new int[]{});
+  }
+
   // The Vigna paper doesn't deal with prefix disjunctions.  For now, we keep the same
   // logic as detailed in the paper, but we may want to address it in future so that tests
   // like the one below will pass


[2/2] lucene-solr:master: LUCENE-8196: Check that the TermIntervalsSource is positioned on the correct term

Posted by ro...@apache.org.
LUCENE-8196: Check that the TermIntervalsSource is positioned on the correct term


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1d6502ce
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1d6502ce
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1d6502ce

Branch: refs/heads/master
Commit: 1d6502cecb94330cd5a793ea82bbfe910c844d7f
Parents: 0989e58
Author: Alan Woodward <ro...@apache.org>
Authored: Tue Apr 3 14:48:19 2018 +0100
Committer: Alan Woodward <ro...@apache.org>
Committed: Tue Apr 3 14:57:06 2018 +0100

----------------------------------------------------------------------
 .../org/apache/lucene/search/intervals/TermIntervalsSource.java | 4 +++-
 .../org/apache/lucene/search/intervals/TestIntervalQuery.java   | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d6502ce/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java b/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java
index b375a01..81578ef 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/intervals/TermIntervalsSource.java
@@ -50,7 +50,9 @@ class TermIntervalsSource extends IntervalsSource {
       throw new IllegalArgumentException("Cannot create an IntervalIterator over field " + field + " because it has no indexed positions");
     }
     TermsEnum te = terms.iterator();
-    te.seekExact(term);
+    if (te.seekExact(term) == false) {
+      return null;
+    }
     PostingsEnum pe = te.postings(null, PostingsEnum.POSITIONS);
     float cost = termPositionsCost(te);
     return new IntervalIterator() {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d6502ce/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java b/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java
index a81ab76..de7341e 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/search/intervals/TestIntervalQuery.java
@@ -149,6 +149,11 @@ public class TestIntervalQuery extends LuceneTestCase {
     checkHits(q, new int[]{ 1, 3, 4, 5 });
   }
 
+  public void testNonExistentTerms() throws IOException {
+    Query q = new IntervalQuery(field, Intervals.ordered(Intervals.term("w0"), Intervals.term("w2")));
+    checkHits(q, new int[]{});
+  }
+
   // The Vigna paper doesn't deal with prefix disjunctions.  For now, we keep the same
   // logic as detailed in the paper, but we may want to address it in future so that tests
   // like the one below will pass