pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alastair McKinley <a.mckinley@analyticsengines.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Cc: teodor@sigaev.ru
Subject: Re: websearch_to_tsquery() and apostrophe inside double quotes
Date: Thu, 10 Oct 2019 09:35:06 -0400
Message-ID: <21225.1570714506@sss.pgh.pa.us> (raw)
In-Reply-To: <DB6PR0202MB29042F00F80B87CE187BD2B6E3940@DB6PR0202MB2904.eurprd02.prod.outlook.com>
References: <DB6PR0202MB29042F00F80B87CE187BD2B6E3940@DB6PR0202MB2904.eurprd02.prod.outlook.com>

Alastair McKinley <a.mckinley@analyticsengines.com> writes:
> I am a little confused about what us being generated by websearch_to_tsquery() in the case of an apostrophe inside double quotes.
> ...

> 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?

I believe it's impossible for that to match anything :-(.
It would require 'o' and 'tool' to match the same lexeme
(one immediately after a 'peter') which of course is impossible.

The underlying tsvector type seems to treat the apostrophe the
same as whitespace; it separates 'o' and 'toole' into
distinct words:

# select to_tsvector('peter o''toole');
       to_tsvector        
--------------------------
 'o':2 'peter':1 'tool':3
(1 row)

So it seems to me that this is a bug: websearch_to_tsquery
should also treat "'" like whitespace.  There's certainly
not anything in its documentation that suggests it should
treat "'" specially.  If it didn't, you'd get

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

which would match this tsvector.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <21225.1570714506@sss.pgh.pa.us>
Permalink:  ../21225.1570714506@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21225.1570714506@sss.pgh.pa.us

 · 

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, a.mckinley@analyticsengines.com, teodor@sigaev.ru
  Subject: Re: websearch_to_tsquery() and apostrophe inside double quotes
  In-Reply-To: <21225.1570714506@sss.pgh.pa.us>
  References: <DB6PR0202MB29042F00F80B87CE187BD2B6E3940@DB6PR0202MB2904.eurprd02.prod.outlook.com> <21225.1570714506@sss.pgh.pa.us>

* 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