pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: sebastian.patino-lang@posteo.net
To: pgsql-bugs@lists.postgresql.org
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: BUG #17691: Unexpected behaviour using ts_headline()
Date: Sun, 20 Nov 2022 12:03:39 +0000
Message-ID: <76717862-8936-41cc-80b0-f8bc0593a0c4@Spark> (raw)
In-Reply-To: <17691-93cef39a14663963@postgresql.org>
References: <17691-93cef39a14663963@postgresql.org>

Hi all,

Tom Lane made me aware that the link is not working and its better anyway to include all data in the bug report directly. Please find the file attached.

@Tom: thanks for the hint!

Regards,
Sebastian
On 19. Nov 2022, 14:05 +0100, PG Bug reporting form <noreply@postgresql.org>, wrote:
> The following bug has been logged on the website:
>
> Bug reference: 17691
> Logged by: Sebastian Patino-Lang
> Email address: sebastian.patino-lang@posteo.net
> PostgreSQL version: 13.9
> Operating system: x86_64-apple-darwin19.6.0
> Description:
>
> I experience unexpected behaviour when using ts_headline() in general, but
> especially when changing MaxFragments. Given the data in
> ts_headline_report.sql [1]
>
> SELECT id,
> ts_headline('english', "texts"."fulltext", to_tsquery('english', 'amazon &
> world'), 'StartSel=<<, StopSel=>>') AS "preview"
> FROM texts;
>
> id=1: Highlight word is the first one in the result. Expectation: highlight
> word is somewhere in the middle.
> id=2: No highlight word at all.
> id=3: Highlight words are the first and last one in the result. Not ideal
> but ok-ish.
>
> SELECT id,
> ts_headline('english', "texts"."fulltext", to_tsquery('english', 'amazon &
> world'), 'MaxFragments=1, StartSel=<<, StopSel=>>') AS "preview"
> FROM texts;
>
> id=1: Highlight word is now in the middle of the result. This is ok.
> id=2: No highlight word at all.
> id=3: Highlight words are in the middle part of the result. This is ok.
>
> SELECT id,
> ts_headline('english', "texts"."fulltext", to_tsquery('english', 'amazon &
> world'), 'MaxFragments=2, StartSel=<<, StopSel=>>') AS "preview"
> FROM texts;
>
> id=1: Correct number of fragments (2) with highlight words are returned.
> id=2: No highlight word at all.
> id=3: Correct number of fragments (2) with highlight words are returned.
>
> SELECT id,
> ts_headline('english', "texts"."fulltext", to_tsquery('english', 'amazon &
> world'), 'MaxFragments=3, StartSel=<<, StopSel=>>') AS "preview"
> FROM texts;
>
> id=1: Wrong number of fragments (2) with highlight words are returned.
> id=2: No highlight word at all.
> id=3: Correct number of fragments (3) with highlight words are returned.
>
> SELECT id,
> ts_headline('english', "texts"."fulltext", to_tsquery('english', 'amazon &
> world'), 'MaxFragments=4, StartSel=<<, StopSel=>>') AS "preview"
> FROM texts;
>
> id=1: Wrong number of fragments (2) with highlight words are returned.
> id=2: No highlight word at all.
> id=3: Correct number of fragments (4) with highlight words are returned.
>
> ... and so on. Until MaxFragments=6 where for id=1 suddenly more fragments
> (4) get returned.
>
> SELECT id,
> ts_headline('english', "texts"."fulltext", to_tsquery('english', 'amazon &
> world'), 'MaxFragments=4, StartSel=<<, StopSel=>>') AS "preview"
> FROM texts;
>
> id=1: Wrong number of fragments (4) with highlight words are returned.
> id=2: No highlight word at all.
> id=3: Correct number of fragments (6) with highlight words are returned.
>
> ... and so on. Until MaxFragments=11 where for id=1 the number of returned
> fragments changes again (5)
>
> SELECT id,
> ts_headline('english', "texts"."fulltext", to_tsquery('english', 'amazon &
> world'), 'MaxFragments=11, StartSel=<<, StopSel=>>') AS "preview"
> FROM texts;
>
> id=1: Wrong number of fragments (5) with highlight words are returned.
> id=2: No highlight word at all.
> id=3: Correct number of fragments (11) with highlight words are returned.
>
> ... and so on. Until MaxFragments=14 where for id=2 suddenly more fragments
> (2) get returned.
>
> SELECT id,
> ts_headline('english', "texts"."fulltext", to_tsquery('english', 'amazon &
> world'), 'MaxFragments=14, StartSel=<<, StopSel=>>') AS "preview"
> FROM texts;
>
> id=1: Wrong number of fragments (5) with highlight words are returned.
> id=2: Wrong number of fragments (2) with highlight words are returned.
> id=3: Correct number of fragments (11) with highlight words are returned.
>
> I stopped testing here, but im sure the strange behaviour and jumps in
> fragment count will continue.
>
> Any ideas?
>
> [1] https://1drv.ms/u/s!AqRGi9iGBWddgZVU_M2iuoRdTzM6tg?e=0OHHnB
>

Attachments:

  ts_headline_report.sql (application/octet-stream, 760.8K) download

view thread (6+ messages)  latest in thread

Message-ID: <76717862-8936-41cc-80b0-f8bc0593a0c4@Spark>
Permalink:  ../76717862-8936-41cc-80b0-f8bc0593a0c4@Spark/
Also on:    postgresql.org/message-id/76717862-8936-41cc-80b0-f8bc0593a0c4@Spark

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: sebastian.patino-lang@posteo.net, tgl@sss.pgh.pa.us
  Subject: Re: BUG #17691: Unexpected behaviour using ts_headline()
  In-Reply-To: <76717862-8936-41cc-80b0-f8bc0593a0c4@Spark>
  References: <17691-93cef39a14663963@postgresql.org> <76717862-8936-41cc-80b0-f8bc0593a0c4@Spark>

* 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