You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Alex Botin <op...@yahoo.fr> on 2004/02/17 23:16:30 UTC
Problem using highlighter package
Hi there !
I downloaded the highlighter package made available by Mark Hardwood on :
http://home.clara.net/markharwood/lucene/highlight.htm
I followed the instructions given on this site to use the package, but when I try to run my application, I get the following message :
" Method rewrite(org.apache.lucene.index.IndexReader)
not found in class org.apache.lucene.search.Query.query = query.rewrite(reader); "
Then, if I remove the instruction "query = query.rewrite(reader);", I get another NoSuchMethodError for org.apache.lucene.search.TermQuery.getTerm()
(A piece of my source code is at the end of this message)
Does anybody have a clue to solve my problem ?
And by the way, can somebody explain me what the query.rewrite() function is used for exactly ?
I thank you all in advance.
Alex.
...
import org.apache.lucene.index.*;
import org.apache.lucene.search.*;
import org.apache.lucene.search.highlight.*;
...
IndexReader reader = IndexReader.open(indexName);
searcher = new IndexSearcher( reader );
Analyzer analyzer = new FrenchAnalyzer();
query = QueryParser.parse(queryString, "contents", analyzer);
query = query.rewrite(reader);
QueryHighlightExtractor highlighter =
new QueryHighlightExtractor(query, new FrenchAnalyzer(),
"<font style=\"background:yellow;\">", "</font>");
int highlightFragmentSizeInBytes = 80;
int maxNumFragmentsRequired = 4;
String fragmentSeparator="...";
String highlightedSummary =
highlighter.getBestFragments(summary, highlightFragmentSizeInBytes,
maxNumFragmentsRequired, fragmentSeparator);
For information, I added
C:\Projets\Lucene\lib\highlighter.jar
C:\Projets\Lucene\lib\lucene-1.3-final.jar
C:\Projets\Lucene\lib\lucene-demos-1.3-final.jar
to my classpath.
---------------------------------
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Créez votre Yahoo! Mail