Re: BUG #16744: ts_headline behaves incorrectly with <-> and proximity operators - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #16744: ts_headline behaves incorrectly with <-> and proximity operators
Date
Msg-id 292536.1606241890@sss.pgh.pa.us
Whole thread Raw
In response to BUG #16744: ts_headline behaves incorrectly with <-> and proximity operators  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #16744: ts_headline behaves incorrectly with <-> and proximity operators
List pgsql-bugs
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



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #16744: ts_headline behaves incorrectly with <-> and proximity operators
Next
From: Maxim Boguk
Date:
Subject: Re: BUG #16739: Temporary files not deleting from data folder on disk