lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject lucene-solr:branch_5_5: LUCENE-7112: WeightedSpanTermExtractor.extractUnknownQuery is only called on queries that could not be extracted.
Date Mon, 11 Apr 2016 15:52:51 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_5_5 8a86b29b0 -> f0fffb602


LUCENE-7112: WeightedSpanTermExtractor.extractUnknownQuery is only called on queries that
could not be extracted.


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

Branch: refs/heads/branch_5_5
Commit: f0fffb60232f6bc6f57da51ffc6de7633ca9093f
Parents: 8a86b29
Author: Adrien Grand <jpountz@gmail.com>
Authored: Fri Mar 25 15:44:31 2016 +0100
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Mon Apr 11 17:43:56 2016 +0200

----------------------------------------------------------------------
 lucene/CHANGES.txt                                   |  6 ++++++
 .../search/highlight/WeightedSpanTermExtractor.java  |  7 ++++---
 .../highlight/custom/HighlightCustomQueryTest.java   | 15 +++++++++++++++
 3 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0fffb60/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 4acc4d2..e003651 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -3,6 +3,12 @@ Lucene Change Log
 For more information on past and future Lucene versions, please see:
 http://s.apache.org/luceneversions
 
+======================= Lucene 5.5.1 =======================
+
+Bug fixes
+
+* LUCENE-7112: WeightedSpanTermExtractor.extractUnknownQuery is only called
+  on queries that could not be extracted. (Adrien Grand)
 
 ======================= Lucene 5.5.0 =======================
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0fffb60/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
----------------------------------------------------------------------
diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
b/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
index 85bf79a..dc4e50a 100644
--- a/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
+++ b/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
@@ -222,12 +222,13 @@ public class WeightedSpanTermExtractor {
         rewritten = origQuery.rewrite(reader);
       }
       if (rewritten != origQuery) {
-        // only rewrite once and then flatten again - the rewritten query could have a speacial
treatment
+        // only rewrite once and then flatten again - the rewritten query could have a special
treatment
         // if this method is overwritten in a subclass or above in the next recursion
         extract(rewritten, boost, terms);
-      } 
+      } else {
+        extractUnknownQuery(query, terms);
+      }
     }
-    extractUnknownQuery(query, terms);
   }
 
   protected void extractUnknownQuery(Query query,

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0fffb60/lucene/highlighter/src/test/org/apache/lucene/search/highlight/custom/HighlightCustomQueryTest.java
----------------------------------------------------------------------
diff --git a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/custom/HighlightCustomQueryTest.java
b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/custom/HighlightCustomQueryTest.java
index 36c6d2a..bbb3bb9 100644
--- a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/custom/HighlightCustomQueryTest.java
+++ b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/custom/HighlightCustomQueryTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.lucene.search.highlight.custom;
 
+import org.apache.lucene.analysis.CannedTokenStream;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.MockTokenFilter;
 import org.apache.lucene.analysis.MockTokenizer;
@@ -35,6 +36,7 @@ import org.apache.lucene.search.highlight.WeightedSpanTermExtractor;
 import org.apache.lucene.util.LuceneTestCase;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Map;
 
 /**
@@ -82,6 +84,19 @@ public class HighlightCustomQueryTest extends LuceneTestCase {
 
   }
 
+  public void testHighlightKnownQuery() throws IOException {
+    WeightedSpanTermExtractor extractor = new WeightedSpanTermExtractor() {
+      @Override
+      protected void extractUnknownQuery(Query query, Map<String,WeightedSpanTerm>
terms) throws IOException {
+        terms.put("foo", new WeightedSpanTerm(3, "foo"));
+      }
+    };
+    Map<String,WeightedSpanTerm> terms = extractor.getWeightedSpanTerms(
+        new TermQuery(new Term("bar", "quux")), 3, new CannedTokenStream());
+    // no foo
+    assertEquals(Collections.singleton("quux"), terms.keySet());
+  }
+
   /**
    * This method intended for use with
    * <tt>testHighlightingWithDefaultField()</tt>


Mime
View raw message