Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly
Date
Msg-id 1995601.1698526000@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly  (Bruce Momjian <bruce@momjian.us>)
Responses Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly
Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly
List pgsql-bugs
Bruce Momjian <bruce@momjian.us> writes:
> Is this documented somewhere?

The docs [1] only say that ts_headline "returns an excerpt from the
document in which terms from the query are highlighted".  This
behavior does not violate that admittedly-weak contract.

IIRC, ts_headline does attempt to find a text fragment or fragments
that fully satisfy the query (e.g., include an exact phrase match)
but it will then highlight all the matching words in the fragment,
not only the location of the phrase match.  I do not agree with the
OP's opinion that that's wrong.  The highlight-em-all approach has its
own value, and in any case it may not be possible to find a full match
that satisfies the function's other constraints such as MaxWords.
Refusing to highlight anything in that event would be unhelpful.

            regards, tom lane

[1] https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE



pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly
Next
From: Pavel Borisov
Date:
Subject: Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly