websearch_to_tsquery() and apostrophe inside double quotes

From: Alastair McKinley <a(dot)mckinley(at)analyticsengines(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: websearch_to_tsquery() and apostrophe inside double quotes
Date: 2019-10-10 11:42:20
Message-ID: DB6PR0202MB29042F00F80B87CE187BD2B6E3940@DB6PR0202MB2904.eurprd02.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I am a little confused about what us being generated by websearch_to_tsquery() in the case of an apostrophe inside double quotes.

Here is an example of searching for a name containing an apostrophe.

The following works as expected:

select to_tsvector('peter o''toole') @@ websearch_to_tsquery('peter o''toole');
?column?
----------
t
(1 row)

When the name is in double quotes, the search fails:

select to_tsvector('peter o''toole') @@ websearch_to_tsquery('"peter o''toole"');
?column?
----------
f
(1 row)

In the first case, websearch_to_tsquery() returns:

select websearch_to_tsquery('peter o''toole');
websearch_to_tsquery
------------------------
'peter' & 'o' & 'tool'
(1 row)

which makes sense to me.

In the second case websearch_to_tsquery() returns something that I can't quite understand:

select websearch_to_tsquery('"peter o''toole"');
websearch_to_tsquery
------------------------------
'peter' <-> ( 'o' & 'tool' )
(1 row)

I am not quite sure what text this will actually match?

Best regards,

Alastair

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Luca Ferrari 2019-10-10 11:58:35 Re: Minimum privilege for Backup and replication
Previous Message Timmy Siu 2019-10-10 11:25:58 Minimum privilege for Backup and replication