lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doron Cohen <>
Subject Re: highlighting
Date Mon, 25 Sep 2006 21:47:45 GMT

"Stelios Eliakis" <> wrote on 23/09/2006 02:39:27:
> I want to extract the Best Fragment (passage) from a text file.
> When I use the following code I take the first fragment that contains my
> query. Nevertheless, the JavaDoc says that the function getBestFragment
> returns the best fragment. Do I something wrong?

That code seems fine to me.

A possible explanation (which I think might be the case here but not sure)
is that getBestFragment*() only accumulates fragments scores for matches of
"unique terms" in the fragment.

Example 1: query = "xy", and the term "xy" appears once in an early
fragment but 3 times in a later fragment. In this case both fragments would
be scored equally, and hence the early fragment would be selected "best"
just because of how the sorting works.

Example 2: query = "xy zw", and the early fragment contains "xy" but a
later fragment contains both "xy" and "zw". In this case the later fragment
would be selected "best".

Does this explain what you see in your program?

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

View raw message