From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stas Obydionnov <stas@hellofyllo.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16744: ts_headline behaves incorrectly with <-> and proximity operators
Date: Wed, 25 Nov 2020 14:40:50 -0500
Message-ID: <501699.1606333250@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKZLNo3TTZFq0WNQVOn_b_Yp97n2tEs+7Zk4oYkq9Fdst___pQ@mail.gmail.com>
References: <16744-861496b4f8f941f2@postgresql.org>
<292536.1606241890@sss.pgh.pa.us>
<CAKZLNo3TTZFq0WNQVOn_b_Yp97n2tEs+7Zk4oYkq9Fdst___pQ@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, stas@hellofyllo.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16744: ts_headline behaves incorrectly with <-> and proximity operators
In-Reply-To: <501699.1606333250@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox