lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r693432 - in /lucene/java/trunk/contrib/highlighter/src: java/org/apache/lucene/search/highlight/ test/org/apache/lucene/search/highlight/
Date Tue, 09 Sep 2008 10:52:51 GMT
Author: markrmiller
Date: Tue Sep  9 03:52:50 2008
New Revision: 693432

URL: http://svn.apache.org/viewvc?rev=693432&view=rev
Log:
LUCENE-1357: SpanScorer does not respect ConstantScoreRangeQuery setting

Modified:
    lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SpanScorer.java
    lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
    lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java

Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SpanScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SpanScorer.java?rev=693432&r1=693431&r2=693432&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SpanScorer.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SpanScorer.java
Tue Sep  9 03:52:50 2008
@@ -25,7 +25,7 @@
   private float maxTermWeight;
   private int position = -1;
   private String defaultField;
-  private boolean highlightCnstScrRngQuery;
+  private static boolean highlightCnstScrRngQuery;
 
   /**
    * @param query
@@ -184,7 +184,7 @@
   /**
    * @return whether ConstantScoreRangeQuerys are set to be highlighted
    */
-  public boolean isHighlightCnstScrRngQuery() {
+  public static boolean isHighlightCnstScrRngQuery() {
     return highlightCnstScrRngQuery;
   }
 
@@ -198,12 +198,12 @@
 
   /**
    * Turns highlighting of ConstantScoreRangeQuery on/off. ConstantScoreRangeQuerys cannot
be
-   * highlighted if you rewrite the query first.
+   * highlighted if you rewrite the query first. Must be called before SpanScorer construction.
    * 
    * @param highlightCnstScrRngQuery
    */
-  public void setHighlightCnstScrRngQuery(boolean highlightCnstScrRngQuery) {
-    this.highlightCnstScrRngQuery = highlightCnstScrRngQuery;
+  public static void setHighlightCnstScrRngQuery(boolean highlight) {
+    highlightCnstScrRngQuery = highlight;
   }
 
   /*

Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java?rev=693432&r1=693431&r2=693432&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
Tue Sep  9 03:52:50 2008
@@ -179,7 +179,7 @@
         sp.setBoost(query.getBoost());
         extractWeightedSpanTerms(terms, sp);
       }
-    } else if (query instanceof ConstantScoreRangeQuery) {
+    } else if (highlightCnstScrRngQuery && query instanceof ConstantScoreRangeQuery)
{
       ConstantScoreRangeQuery q = (ConstantScoreRangeQuery) query;
       Term lower = new Term(fieldName, q.getLowerVal());
       Term upper = new Term(fieldName, q.getUpperVal());

Modified: lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java?rev=693432&r1=693431&r2=693432&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
Tue Sep  9 03:52:50 2008
@@ -488,9 +488,10 @@
 
       tokenStream = new CachingTokenFilter(analyzer.tokenStream(HighlighterTest.FIELD_NAME,
           new StringReader(text)));
+      
+      SpanScorer.setHighlightCnstScrRngQuery(true);
       scorer = new SpanScorer(query, HighlighterTest.FIELD_NAME, (CachingTokenFilter) tokenStream);
-      scorer.setHighlightCnstScrRngQuery(true);
-
+      
       Highlighter highlighter = new Highlighter(this, scorer);
 
       ((CachingTokenFilter) tokenStream).reset();



Mime
View raw message