From fdf05bd0882c9fa2d3530e170e977844e2a4900c Mon Sep 17 00:00:00 2001 From: Mark Harwood Date: Sat, 19 Feb 2005 19:51:04 +0000 Subject: [PATCH] Fixed missing fieldname in API git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@154447 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/lucene/search/highlight/Highlighter.java | 5 +++-- .../org/apache/lucene/search/highlight/HighlighterTest.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java b/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java index ced1fe208c7..979078b9e45 100644 --- a/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java +++ b/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java @@ -67,13 +67,14 @@ public class Highlighter * @param analyzer the analyzer that will be used to split text * into chunks * @param text text to highlight terms in + * @param fieldName Name of field used to influence analyzer's tokenization policy * * @return highlighted text fragment or null if no terms found */ - public final String getBestFragment(Analyzer analyzer, String text) + public final String getBestFragment(Analyzer analyzer, String fieldName,String text) throws IOException { - TokenStream tokenStream = analyzer.tokenStream("field", new StringReader(text)); + TokenStream tokenStream = analyzer.tokenStream(fieldName, new StringReader(text)); return getBestFragment(tokenStream, text); } diff --git a/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java b/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java index 5ea3ceb5d39..0855c2918e8 100644 --- a/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java +++ b/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java @@ -173,7 +173,7 @@ public class HighlighterTest extends TestCase implements Formatter for (int i = 0; i < hits.length(); i++) { String text = hits.doc(i).get(FIELD_NAME); - highlighter.getBestFragment(analyzer, text); + highlighter.getBestFragment(analyzer, FIELD_NAME,text); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 4);