From: Tom Lane <tgl@sss.pgh.pa.us>
To: stas@hellofyllo.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16744: ts_headline behaves incorrectly with <-> and proximity operators
Date: Tue, 24 Nov 2020 13:18:10 -0500
Message-ID: <292536.1606241890@sss.pgh.pa.us> (raw)
In-Reply-To: <16744-861496b4f8f941f2@postgresql.org>
References: <16744-861496b4f8f941f2@postgresql.org>
PG Bug reporting form <noreply@postgresql.org> writes:
> When running the following code
> select ts_headline('Alpha Beta Gama', phraseto_tsquery ('alpha gama'))
> or
> select ts_headline('Alpha Beta Gama', to_tsquery ('alpha <-> gama'))
> I would expect the result be not to be highlighted,
That's operating as designed, I think. Per the code comment:
* If we found nothing acceptable, select min_words words starting at
* the beginning.
The expectation really is that it's on you to not select documents that
don't match your search query. Once you've selected a document to
display, ts_headline() is just going to do the best it can to produce
something useful. "Not highlight anything" wasn't deemed particularly
useful, and I agree with that judgment.
Also, once it's selected a document fragment to display, it will highlight
all words within that fragment that appear in the search query, whether or
not the particular occurrence is part of the match-if-any. Thus
regression=# select ts_headline('Alpha Beta Gama foo bar alpha gama', phraseto_tsquery ('alpha gama'));
ts_headline
----------------------------------------------------------------
<b>Alpha</b> Beta <b>Gama</b> foo bar <b>alpha</b> <b>gama</b>
(1 row)
Again, this is a value judgment about what's useful.
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: <292536.1606241890@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