lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
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 <> 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.


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

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

View raw message