lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Borkenhagen, Michael (ofd-ko zdfin)" <Michael.Borkenha...@ofd-ko.fin-rlp.de>
Subject AW: Using term-highlighter
Date Fri, 21 Feb 2003 07:01:13 GMT
You have to write a class which implements the TermHighlighter Interface for
example like this 

public class MyHighlighter implements TermHighlighter {

  public String highlightTerm (String term){
    return "<font class='highlight'>" + term + "</font>";
  }

}

Use this class in your Query after searching :

Document doc = this.ivHits.doc(i);
String doctitle = doc.get(Konstanten.F_TITLE);
doctitle = LuceneTools.highlightTerms(doctitle, new MyHighlighter(),
	  this.ivQuery, analyzer);

Regards,
Michael

-----Urspr√ľngliche Nachricht-----
Von: Harpreet S Walia [mailto:harpreet@sansuisoftware.com]
Gesendet: Freitag, 21. Februar 2003 07:37
An: Lucene Users List
Betreff: Using term-highlighter


Hi,

I am trying to use the term-highlighter posted on the contribution page for
lucene. I downloaded the files and made the changes mentioned in the
whitepaper to the classes in the  lucene search package.

can anbody please tell me, how to invoke the highligher while searching.
currently i am performing the searches as follows
            
            org.apache.lucene.search.Searcher searcher = new
IndexSearcher(indexPath);
            Query query = QueryParser.parse(srchqry,field, new
SimpleAnalyzer());
            Hits hits = searcher.search(query);

what changes will be needed in these search steps.

Thanks in advance !

Regards,
Harpreet




---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message