lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r673220 - in /lucene/java/trunk/contrib/highlighter/src: java/org/apache/lucene/search/highlight/Highlighter.java test/org/apache/lucene/search/highlight/HighlighterTest.java
Date Tue, 01 Jul 2008 21:44:34 GMT
Author: markrmiller
Date: Tue Jul  1 14:44:33 2008
New Revision: 673220

URL: http://svn.apache.org/viewvc?rev=673220&view=rev
Log:
LUCENE-1321: Highlight fragment does not extend to maxDocCharsToAnalyze

Modified:
    lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.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/Highlighter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java?rev=673220&r1=673219&r2=673220&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java
Tue Jul  1 14:44:33 2008
@@ -285,7 +285,7 @@
 					(lastEndOffset < text.length()) 
 					&&
 //					and that text is not too large...
-					(text.length()< maxDocCharsToAnalyze)
+					(text.length()<= maxDocCharsToAnalyze)
 				)				
 			{
 				//append it to the last fragment

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=673220&r1=673219&r2=673220&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 Jul  1 14:44:33 2008
@@ -876,6 +876,27 @@
     helper.start();
 
   }
+  
+  public void testMaxSizeEndHighlight() throws Exception {
+    TestHighlightRunner helper = new TestHighlightRunner() {
+      public void run() throws Exception {
+        String stopWords[] = { "in", "it" };
+        TermQuery query = new TermQuery(new Term("text", "searchterm"));
+
+        String text = "this is a text with searchterm in it";
+        SimpleHTMLFormatter fm = new SimpleHTMLFormatter();
+        Highlighter hg = getHighlighter(query, "text", new StandardAnalyzer(
+            stopWords).tokenStream("text", new StringReader(text)), fm);
+        hg.setTextFragmenter(new NullFragmenter());
+        hg.setMaxDocCharsToAnalyze(36);
+        String match = hg.getBestFragment(new StandardAnalyzer(stopWords), "text", text);
+        assertTrue(
+            "Matched text should contain remainder of text after highlighted query ",
+            match.endsWith("in it"));
+      }
+    };
+    helper.start();
+  }
 
   public void testUnRewrittenQuery() throws Exception {
     TestHighlightRunner helper = new TestHighlightRunner() {



Mime
View raw message