pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Allan Jardine <allan.jardine@sprymedia.co.uk>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Full text search - wildcard and a stop word
Date: Tue, 22 Feb 2022 10:56:23 -0500
Message-ID: <705272.1645545383@sss.pgh.pa.us> (raw)
In-Reply-To: <CAAMbBLtckoNmFp6irVXsKcZufM6_DiQGN2vtHhWVgofESsE11g@mail.gmail.com>
References: <CAAMbBLtckoNmFp6irVXsKcZufM6_DiQGN2vtHhWVgofESsE11g@mail.gmail.com>

Allan Jardine <allan.jardine@sprymedia.co.uk> writes:
> => select to_tsquery('all:*');
> NOTICE:  text-search query contains only stop words or doesn't contain
> lexemes, ignored
>  to_tsquery
> ------------
> (1 row)

> I get why that is happening - the notification basically details it, but
> the wildcard at the end seems to me that it should return `'all':*` in this
> case? Is this by design or could it be considered a bug?

It's a hard problem.  If we don't normalize the presented word, we risk
not matching cases that users would expect to match (because the word
is going to be compared to data that probably *was* normalized).

In this particular case, you can skip the normalization by just not
using to_tsquery:

n=# select 'all:*'::tsquery;
 tsquery 
---------
 'all':*
(1 row)

but that might or might not be what you want in general.

Perhaps the ideal behavior here would be "normalize, but don't throw away
stopwords", but unfortunately our dictionary APIs don't support that.

			regards, tom lane





view thread (2+ messages)

Message-ID: <705272.1645545383@sss.pgh.pa.us>
Permalink:  ../705272.1645545383@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/705272.1645545383@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, allan.jardine@sprymedia.co.uk
  Subject: Re: Full text search - wildcard and a stop word
  In-Reply-To: <705272.1645545383@sss.pgh.pa.us>
  References: <CAAMbBLtckoNmFp6irVXsKcZufM6_DiQGN2vtHhWVgofESsE11g@mail.gmail.com> <705272.1645545383@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