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 <[email protected]> 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
> <[email protected]>wrote:
>
>> Am i coding it wrongly ...please reply.
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]