lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: PostingsHighlighter to highlight the first Match ion the document
Date Mon, 22 Jul 2013 18:40:39 GMT
On Mon, Jul 22, 2013 at 9:57 AM, VIGNESH S <vigneshklncit@gmail.com> wrote:
> Hi Mike,
>
> I am indexing at the document level that is full book to a field.For
> Example iam indexing the full book which contains some term say Android at
> the first page,last page.
>
> when i do a search,I will get the document.
>
> In that document ,i need to highlight only the first  sentence which
> matches the search query "Android".say in first page.
>
> is it possible to use PostingsHighlighter to acheive this functionality.

Yes.

PostingsHighlighter lets you specify your own PassageScorer.  Each
passage that had 1 or more term matches is sent to the PassageScorer,
in the order those passages occurred in the document.

So if your scorer just assigns an insanely great score to the first
passage it sees, then PostingsHighlighter will always pick the first
passage that matched.

But, I'm not sure this is a good idea: the default scorer gives better
scores to passages that have more terms matching, diverse terms
matching, etc., which you'd be disabling by just picking the first
passage that matches.

Mike McCandless

http://blog.mikemccandless.com

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


Mime
View raw message