Re: [feature request] ts_headline should have an option to highlight only full matches of <-> expressions

From: Jake North <jknr(at)tuta(dot)io>
To: Pgsql Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [feature request] ts_headline should have an option to highlight only full matches of <-> expressions
Date: 2022-01-08 19:26:51
Message-ID: Msv7TjN--3-2@tuta.io
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

8 Jan 2022, 20:09 by jknr(at)tuta(dot)io:

> Hi,
>
> I am using Postgres' full text search since some time now and overall it's working really well for me. However one issue I have is that ts_headline highlights partial matches of FOLLOWED BY (<->) expressions, e.g.
>
> SELECT ts_headline('some words and some more words', to_tsquery('some<->words'));
>
> gives
>
> <b>some</b> <b>words</b> and <b>some</b> more <b>words</b>
>
> while I expect
>
> <b>some words</b> and some more words
>
> I think the highlights of partial matches is in most cases not useful and confusing to end users, they may think the search did not recognize they requested the words to be consecutive. Google also does not highlight partial matches it seems.
>
> I suspect to implement this would require substantial changes to ts_headline since it seems to treat the lexemes independently, but it would be a big improvement and should be the default behaviour.
>
> Best regards,
> Jake N
>

PS   I found this issue brought up here https://stackoverflow.com/questions/69512416/is-ts-headline-intended-to-highlight-non-matching-parts-of-the-query-which-it but the real issue was not recognised is seems

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2022-01-08 19:50:19 Re: \dP and \dX use ::regclass without "pg_catalog."
Previous Message Aliaksandr Kalenik 2022-01-08 19:20:45 Re: [PATCH] reduce page overlap of GiST indexes built using sorted method