Stas Obydionnov <stas@hellofyllo.com> writes:
> Probably I provided a bad example.
> Here is another one from a similar bug that was opened a couple of years
> ago and was not answered.
> Assuming the following query:
> SELECT ts_headline('English',
> 'This Commercial Bank does not have any Equity in Europe but European
> Commercial Bank does',
> to_tsquery('English','European <-> Commercial <-> Bank')::tsquery);
> The returned result is:
> This <b>Commercial</b> <b>Bank</b> does not have any Equity in Europe but
> <b>European</b> <b>Commercial</b> <b>Bank</b> does
> This highlights the words Commercial & Bank separately in addition
> to European Commercial Bank.
> However, the correct output expected should be:
> This Commercial Bank does not have any Equity in Europe but <b>European</b>
> <b>Commercial</b> <b>Bank</b> does
[ shrug... ] Whether that's more correct than the current behavior
is a matter of opinion. As I said, the ts_headline code highlights
all matching words within whatever fragment it selects. It does
make an effort to locate a fragment that satisfies the query as
written, but that doesn't mean there won't be additional word
matches within the fragment. (In fact, if I'm reading the code
correctly, it actually gives preference to fragments having more
matching words, which is why you don't just get "<b>European</b>
<b>Commercial</b> <b>Bank</b>" here.) I think it's reasonable to
consider that highlighting the additional matches is a useful thing
to do, so I'm disinclined to change this longstanding behavior.
regards, tom lane