Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nMXWf-0005RJ-J9 for pgsql-general@arkaria.postgresql.org; Tue, 22 Feb 2022 15:56:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nMXWe-0007uX-2B for pgsql-general@arkaria.postgresql.org; Tue, 22 Feb 2022 15:56:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nMXWd-0007uO-O0 for pgsql-general@lists.postgresql.org; Tue, 22 Feb 2022 15:56:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nMXWb-0007rK-Bh for pgsql-general@lists.postgresql.org; Tue, 22 Feb 2022 15:56:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 21MFuNCA705273; Tue, 22 Feb 2022 10:56:24 -0500 From: Tom Lane To: Allan Jardine cc: pgsql-general@lists.postgresql.org Subject: Re: Full text search - wildcard and a stop word In-reply-to: References: Comments: In-reply-to Allan Jardine message dated "Tue, 22 Feb 2022 15:22:41 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <705271.1645545383.1@sss.pgh.pa.us> Date: Tue, 22 Feb 2022 10:56:23 -0500 Message-ID: <705272.1645545383@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Allan Jardine 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