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 1nQAy3-0005Uh-SZ for pgsql-general@arkaria.postgresql.org; Fri, 04 Mar 2022 16:39:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nQAy2-0008N7-R0 for pgsql-general@arkaria.postgresql.org; Fri, 04 Mar 2022 16:39:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nQAy2-0008Ml-78 for pgsql-general@lists.postgresql.org; Fri, 04 Mar 2022 16:39:46 +0000 Received: from smtpvbsrv1.mitre.org ([198.49.146.234]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nQAxy-0002Gx-Vl for pgsql-general@lists.postgresql.org; Fri, 04 Mar 2022 16:39:45 +0000 Received: from smtpvbsrv1.mitre.org (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with SMTP id C42085F6C5A; Fri, 4 Mar 2022 11:39:40 -0500 (EST) Received: from smtprhbv1.mitre.org (unknown [10.20.0.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtpvbsrv1.mitre.org (Postfix) with ESMTPS id 9C5735F6BF8; Fri, 4 Mar 2022 11:39:40 -0500 (EST) Received: from [100.64.0.1] (f5-infra-prod-vl2218-fip.mitre.org [10.20.118.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtprhbv1.mitre.org (Postfix) with ESMTPS id EE6B493E6E2; Fri, 4 Mar 2022 11:39:39 -0500 (EST) Message-ID: <7ee2afc2-dcf7-2bc9-3092-8ca58ed2b880@mitre.org> Date: Fri, 4 Mar 2022 11:39:39 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [EXT] Re: Looking for tips on improving full-text search quality in Postgres Content-Language: en-US To: Tom Lane , Bruce Momjian Cc: Atri Sharma , pgsql-general@lists.postgresql.org References: <7ce98668-3fdb-254a-fa81-f1c4d09e6607@mitre.org> <23582_1646407541_62222F75_23582_337_5_YiIvdEhT5BecGxPY@momjian.us> <4b5afb83-3e90-17c7-2650-9bd521e958a7@mitre.org> <3886250.1646410186@sss.pgh.pa.us> From: "Bayer, Samuel" In-Reply-To: <3886250.1646410186@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-MITRE: 8GQsMWxq66rxk57w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mitre.org; h=message-id:date:mime-version:subject:to:cc:references:from:in-reply-to:content-type:content-transfer-encoding; s=BTxNELhf; bh=5OCoHhhe4OE/Wvi6pn/5PBRrTwRN5jjrLIjQFA2PEv4=; b=Erj2LzGmx29xyO4XpjP8GoU+lIeZbaEBiv5yV4mNbvJyQWwJMllR5CAO6Mr96z3bKXhM8gluixEdofJgaDQRx2RC0MlgyuWf5+xsR/06VOeZwMXYxXj6vK7XYu0ec6T4h3Dh7DOB5CnBmiQ2Ykoh+15cSJiAOUj0ky6x3/tKdjA= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I've tried both ranking functions. I've tried a variety of the normalization settings. I'm using the standard English language configuration. Postgres 13. I do understand your FTS philosophy - I suppose I'm looking for guidance about how best to approximate the search capability in Solr using the FTS pieces you have. One concrete question, I suppose, is: the classic TF/IDF search strategy relies on inverse document frequency, which looks across the corpus. I can't tell whether that corpus-wide frequency information is taken into account in either ranking function. I don't know if Solr weights earlier tokens more heavily, but I wouldn't be surprised if it does. On 3/4/22 11:09 AM, Tom Lane wrote: > Bruce Momjian writes: >> On Fri, Mar 4, 2022 at 10:41:16AM -0500, Bayer, Samuel wrote: >>> I apologize for not being able to be more specific. > >> I know it is hard to quantify. Is it possible that Postgres is treating >> all the terms equally, while Solr is prioritizing terms that are earlier >> in the document? > > A few basic questions: > > * which ranking function are you using? > > * with what options? > > * which PG version exactly? > > As far as I can see from a quick look at the docs, neither > ts_rank() nor ts_rank_cd() consider "earlier in the document" > to be an interesting consideration. They do have the ability > to prefer terms that have been marked as having a higher weight, > but you'd need to do some setup work to make that useful --- > basically, you'd have to separate out the title or other metadata > and apply setweight() to it while building the tsvectors. > > I wouldn't be surprised if Solr has some well-tuned default > heuristics that mean that you don't have to work hard to get > good results from it. The current state of our FTS features > is more like "here's all the parts, but you have to build the > behavior you want". > > ISTM that our FTS features have basically been on autopilot > since they went in. I'd sort of hoped that we'd see more > parsers, more ranking functions, etc, over time ... but nothing > like that has happened. I'm not sure if that's just lack of > interest, or if people find the code too difficult to work with. > > regards, tom lane