Yes , thats the expected output. Now put that full content[whatever the searcer returned] in the html page alongwith the styling for the same, and you will see the matches in yellow [you chose yellow as color for highlighting].
--KK On Thu, May 28, 2009 at 11:42 AM, Ritu choudhary <ritu.it...@gmail.com>wrote: > I have added the lines you suggested and now its giving the following > output , still can't get what's wrong... > > THE CHANGES I HAVE DONE: > > SimpleHTMLFormatter formatter = > new SimpleHTMLFormatter("<span class=\"highlight\">", > "</span>"); > Highlighter highlighter = new Highlighter(formatter, new > QueryScorer(query)); > > int maxNumFragmentsRequired=200; > String FragmentSeparator="..."; > Fragmenter fragmenter = new SimpleFragmenter(50); > > highlighter.setTextFragmenter(fragmenter); > > TokenStream tokenStream=analyzer.tokenStream(FIELD_NAME,new > StringReader(text)); > String > result=highlighter.getBestFragments(tokenStream,text,maxNumFragmentsRequired,FragmentSeparator); > > System.out.println( "This is the result "+result); > > > OUTPUT: > > Content field found--->>accept > This is the result <span class="highlight">accept</span> > > > On 28/05/2009, KK <dioxide.softw...@gmail.com> wrote: > > Yes, your code is wrong! > > Where is the highlighter span/formatter, because from your code what I > can > > see is that you are just passsing the score to Queryscorer, instead you > > should pass both queryscore as well as formatter > > From my previous mail you can see the following code and mimic the same > and > > it will work without any hitch, > > > > QueryScorer scorer = new QueryScorer(phrase); > > > > SimpleHTMLFormatter formatter = > > new SimpleHTMLFormatter("<span class=\"highlight\">", > > "</span>"); > > Highlighter highlighter = new Highlighter(formatter, scorer); > > > > and this is your code, > > > > Highlighter highlighter = new Highlighter(new QueryScorer(query)); > > > > You missed the formatter altogether but you added thestyler at the end, > > though. Add it and it will work like a charm. > > > > --KK > > > > > > > > > > > > On Wed, May 27, 2009 at 10:40 PM, Ritu choudhary > > <ritu.it...@gmail.com>wrote: > > > >> Am i coding it wrongly ...please reply. > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >