lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Agrawal, Aashish \(IT\)" <Aashish.Agra...@morganstanley.com>
Subject problem with highlighter
Date Thu, 30 Oct 2008 03:07:48 GMT
Hi, 
 
I am using RegexQuery and Highlighter, my query works fine and i get the
matches, but there is nothing being printed out from highlighter ? 
at the same time, if I use Query, it works fine . 
is something wrong with the code below ? 
code --
 
   //line -->input string (ie ".*out")
   RegexQuery query = new RegexQuery (new Term (field, line));
   QueryScorer scorer = new QueryScorer(query);
   SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("", "");
   Highlighter highlighter = new Highlighter(formatter, scorer);
   Highlighter high = new Highlighter(formatter, scorer);
   Fragmenter fragmenter = new NullFragmenter();
   Fragmenter fragment = new SimpleFragmenter(250);
   highlighter.setTextFragmenter(fragmenter);
   high.setTextFragmenter(fragment);
   System.out.println("Searching for: " + query.toString(field));
 
  Hits hits = searcher.search(query);
 
snip..
 
   TokenStream lines = analyzer.tokenStream("filedata", new
StringReader(doc.get("filedata")));
   CachingTokenFilter filter = new CachingTokenFilter(lines);
   String highlightedLines = highlighter.getBestFragment(filter,
doc.get("filedata"));
   filter.reset();
   String highlight = high.getBestFragments(filter,
doc.get("filedata"),5, "........next match..........");
   System.out.println (highlight);    //nothing printed out
   System.out.println (highlightedLines); //nothing pritned out. 
 
 
thanks, 
Aashish Agrawal
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to
waive confidentiality or privilege. Use of this email is prohibited when received in error.

Mime
  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message