lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject svn commit: r1724051 - in /lucene/dev/branches/lucene_solr_5_4: ./ lucene/ lucene/CHANGES.txt lucene/core/ lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java
Date Mon, 11 Jan 2016 14:58:38 GMT
Author: jpountz
Date: Mon Jan 11 14:58:38 2016
New Revision: 1724051

URL: http://svn.apache.org/viewvc?rev=1724051&view=rev
Log:
LUCENE-6929: Fix SpanNotQuery to not ignore the pre/post parameters when rewriting.

Modified:
    lucene/dev/branches/lucene_solr_5_4/   (props changed)
    lucene/dev/branches/lucene_solr_5_4/lucene/   (props changed)
    lucene/dev/branches/lucene_solr_5_4/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_5_4/lucene/core/   (props changed)
    lucene/dev/branches/lucene_solr_5_4/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
    lucene/dev/branches/lucene_solr_5_4/lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java

Modified: lucene/dev/branches/lucene_solr_5_4/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_4/lucene/CHANGES.txt?rev=1724051&r1=1724050&r2=1724051&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_4/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_5_4/lucene/CHANGES.txt Mon Jan 11 14:58:38 2016
@@ -17,6 +17,9 @@ Bug Fixes
 * SOLR-7865: BlendedInfixSuggester was returning too many results
   (Arcadius Ahouansou via Mike McCandless)
 
+* LUCENE-6929: Fix SpanNotQuery rewriting to not drop the pre/post parameters.
+  (Tim Allison via Adrien Grand)
+
 ======================= Lucene 5.4.0 =======================
 
 New Features

Modified: lucene/dev/branches/lucene_solr_5_4/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_4/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java?rev=1724051&r1=1724050&r2=1724051&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_4/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
(original)
+++ lucene/dev/branches/lucene_solr_5_4/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
Mon Jan 11 14:58:38 2016
@@ -200,11 +200,10 @@ public final class SpanNotQuery extends
     SpanQuery rewrittenInclude = (SpanQuery) include.rewrite(reader);
     SpanQuery rewrittenExclude = (SpanQuery) exclude.rewrite(reader);
     if (rewrittenInclude != include || rewrittenExclude != exclude) {
-      return new SpanNotQuery(rewrittenInclude, rewrittenExclude);
+      return new SpanNotQuery(rewrittenInclude, rewrittenExclude, pre, post);
     }
     return super.rewrite(reader);
   }
-
     /** Returns true iff <code>o</code> is equal to this. */
   @Override
   public boolean equals(Object o) {

Modified: lucene/dev/branches/lucene_solr_5_4/lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_4/lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java?rev=1724051&r1=1724050&r2=1724051&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_4/lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java
(original)
+++ lucene/dev/branches/lucene_solr_5_4/lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java
Mon Jan 11 14:58:38 2016
@@ -17,21 +17,26 @@ package org.apache.lucene.search.spans;
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.util.List;
+
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexReaderContext;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.ReaderUtil;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.CheckHits;
 import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.FuzzyQuery;
 import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.PrefixQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.TermQuery;
@@ -40,10 +45,13 @@ import org.apache.lucene.search.similari
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
 
-import java.io.IOException;
-import java.util.List;
-
-import static org.apache.lucene.search.spans.SpanTestUtil.*;
+import static org.apache.lucene.search.spans.SpanTestUtil.assertFinished;
+import static org.apache.lucene.search.spans.SpanTestUtil.assertNext;
+import static org.apache.lucene.search.spans.SpanTestUtil.spanNearOrderedQuery;
+import static org.apache.lucene.search.spans.SpanTestUtil.spanNearUnorderedQuery;
+import static org.apache.lucene.search.spans.SpanTestUtil.spanNotQuery;
+import static org.apache.lucene.search.spans.SpanTestUtil.spanOrQuery;
+import static org.apache.lucene.search.spans.SpanTestUtil.spanTermQuery;
 
 public class TestSpans extends LuceneTestCase {
   private IndexSearcher searcher;
@@ -87,7 +95,10 @@ public class TestSpans extends LuceneTes
     "u2 u1 xx u2",
     "u1 u2 xx u2",
     "t1 t2 t1 t3 t2 t3",
-    "s2 s1 s1 xx xx s2 xx s2 xx s1 xx xx xx xx xx s2 xx"
+    "s2 s1 s1 xx xx s2 xx s2 xx s1 xx xx xx xx xx s2 xx",
+    "r1 s11",
+    "r1 s21"
+
   };
   
   private void checkHits(Query query, int[] results) throws IOException {
@@ -375,7 +386,25 @@ public class TestSpans extends LuceneTes
     reader.close();
     dir.close();
   }
-  
+
+  public void testSpanNotWithMultiterm() throws Exception {
+    SpanQuery q = spanNotQuery(
+        spanTermQuery(field, "r1"),
+        new SpanMultiTermQueryWrapper<>(new PrefixQuery(new Term(field, "s1"))),3,3);
+    checkHits(q,  new int[] {14});
+
+    q = spanNotQuery(
+        spanTermQuery(field, "r1"),
+        new SpanMultiTermQueryWrapper<>(new FuzzyQuery(new Term(field, "s12"), 1, 2)),3,3);
+    checkHits(q,  new int[] {14});
+
+    q = spanNotQuery(
+        new SpanMultiTermQueryWrapper<>(new PrefixQuery(new Term(field, "r"))),
+        spanTermQuery(field, "s21"),3,3);
+    checkHits(q,  new int[] {13});
+
+
+  }
   
   public void testSpanNots() throws Throwable{
      assertEquals("SpanNotIncludeExcludeSame1", 0, spanCount("s2", "s2", 0, 0), 0);



Mime
View raw message