lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: How to extract matching terms for a document given a query
Date Wed, 16 Jun 2004 20:06:03 GMT
>>The reason the current highlighter is not suitable for me, is that the
>>content of the document is not stored in the index

That shouldn't present a problem.
The working code example below was from a recent email discussion I had with someone who was
text in a database. This simple example works shows highlighting working with no index in

===Begin code====
Analyzer a = new StandardAnalyzer();
Query q = QueryParser.parse("jennifer lopez","cached",a);
String s = "the unofficial home page Britney Spears Elizabeth Hurley Kirsten Dunst Anna Kournikova
Katie Holmes Katherine Heigl Jessica Alba Alyson Hannigan Jennifer Lopez Sarah Michelle Gellar";
Highlighter highlighter = new Highlighter(new QueryScorer(q));
TokenStream tokenstream = a.tokenStream("cached",new;
 String summary = highlighter.getBestFragments(tokenstream,s,3,"...");
=== end code =====


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message