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 1mYx4j-00024h-4M for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Oct 2021 21:06:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mYx4g-0007KW-C5 for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Oct 2021 21:06:38 +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 1mYx4g-0007KO-5c for pgsql-bugs@lists.postgresql.org; Fri, 08 Oct 2021 21:06:38 +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 1mYx4Z-00078m-SG for pgsql-bugs@lists.postgresql.org; Fri, 08 Oct 2021 21:06:37 +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 198L6Rsc008756; Fri, 8 Oct 2021 17:06:27 -0400 From: Tom Lane To: Pavel Borisov cc: mnelson@binarykeep.com, PostgreSQL mailing lists Subject: Re: Text search prefix matching and stop words In-reply-to: References: <039b712e-e02f-4470-b6b4-7f810cc1bcb5@www.fastmail.com> Comments: In-reply-to Pavel Borisov message dated "Sat, 09 Oct 2021 00:30:41 +0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8754.1633727187.1@sss.pgh.pa.us> Date: Fri, 08 Oct 2021 17:06:27 -0400 Message-ID: <8755.1633727187@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Pavel Borisov writes: >> Prefix matching should not omit stop words, as matching lexemes may >> legitimately begin with stop words. > I am not sure that it is a bug. I think this is a way how to_tsquery > conversion work: stopwords first then template processing. I concur with the OP that this is a bug, or at least that it'd be nice if it worked better. But I'm not sure we can make it better. The basic design of our text search stuff combined the functions of normalization and stop-word-suppression into a single dictionary stack, so that it's impossible to ask for just one of those to happen. But if we skip applying the dictionaries at all for a prefix item, then word normalization doesn't happen, which would create a different set of unexpected-failure-to-match conditions. (So your proposed workaround of casting directly to tsquery just moves the problem somewhere else.) I think we could only fix this with a dictionary API change that allows telling the dictionaries not to suppress stopwords. Not sure how practical that is. If we'd had the prefix-match feature from the beginning, maybe it'd have occurred to us that we needed that API option ... but we didn't. regards, tom lane