Fixed missing fieldname in API

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@154447 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Harwood 2005-02-19 19:51:04 +00:00
parent 05d0335dcd
commit fdf05bd088
2 changed files with 4 additions and 3 deletions

View File

@ -67,13 +67,14 @@ public class Highlighter
* @param analyzer the analyzer that will be used to split <code>text</code> * @param analyzer the analyzer that will be used to split <code>text</code>
* into chunks * into chunks
* @param text text to highlight terms in * @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 * @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 throws IOException
{ {
TokenStream tokenStream = analyzer.tokenStream("field", new StringReader(text)); TokenStream tokenStream = analyzer.tokenStream(fieldName, new StringReader(text));
return getBestFragment(tokenStream, text); return getBestFragment(tokenStream, text);
} }

View File

@ -173,7 +173,7 @@ public class HighlighterTest extends TestCase implements Formatter
for (int i = 0; i < hits.length(); i++) for (int i = 0; i < hits.length(); i++)
{ {
String text = hits.doc(i).get(FIELD_NAME); 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); assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 4);