Re: Rethinking our fulltext phrase-search implementation
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@postgreSQL.org
Date: 2016-12-20T20:22:12Z
Lists: pgsql-hackers
Attachments
- fix-phrase-search.patch (text/x-diff) patch
I wrote:
> I've been thinking about how to fix the problem Andreas Seltenreich
> reported at
> https://postgr.es/m/87eg1y2s3x.fsf@credativ.de
Attached is a proposed patch that deals with the problems discussed
here and in <26706.1482087250@sss.pgh.pa.us>. Is anyone interested
in reviewing this, or should I just push it?
BTW, I noticed that ts_headline() seems to not behave all that nicely
for phrase searches, eg
regression=# SELECT ts_headline('simple', '1 2 3 1 3'::text, '2 <-> 3', 'ShortWord=0');
ts_headline
--------------------------------
1 <b>2</b> <b>3</b> 1 <b>3</b>
(1 row)
Highlighting the second "3", which is not a match, seems pretty dubious.
Negative items are even worse, they don't change the results at all:
regression=# SELECT ts_headline('simple', '1 2 3 1 3'::text, '!2 <-> 3', 'ShortWord=0');
ts_headline
--------------------------------
1 <b>2</b> <b>3</b> 1 <b>3</b>
(1 row)
However, the code involved seems unrelated to the present patch, and
it's also about as close to completely uncommented as I've seen anywhere
in the PG code base. So I'm not excited about touching it.
regards, tom lane
Commits
-
Fix strange behavior (and possible crashes) in full text phrase search.
- 4e2477b7b8b6 9.6.2 landed
- 89fcea1ace40 10.0 landed
-
Fix handling of phrase operator removal while removing tsquery stopwords.
- 2604438472c8 10.0 landed
- 3f07eff10479 9.6.2 landed