Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cetlU-0007gc-Sx for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Feb 2017 01:24:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cetlT-0000X0-NU for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Feb 2017 01:24:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cetlT-0000Wo-69 for pgsql-bugs@postgresql.org; Sat, 18 Feb 2017 01:24:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cetlM-0001Iv-3z for pgsql-bugs@postgresql.org; Sat, 18 Feb 2017 01:24:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v1I1OPBO011188; Fri, 17 Feb 2017 20:24:25 -0500 From: Tom Lane To: bjorn@eventmy.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14552: tsquery converts AND operator into OR when nested inside OR operations In-reply-to: <20170218003621.6098.76708@wrigleys.postgresql.org> References: <20170218003621.6098.76708@wrigleys.postgresql.org> Comments: In-reply-to bjorn@eventmy.com message dated "Sat, 18 Feb 2017 00:36:21 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11186.1487381065.1@sss.pgh.pa.us> Date: Fri, 17 Feb 2017 20:24:25 -0500 Message-ID: <11187.1487381065@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org bjorn@eventmy.com writes: > Working correctly, no results: > SELECT ts_rank(to_tsvector('lets eat a cat'), ('fat & bat | rat'::tsquery && > 'cat'::tsquery)); > ts_rank > --------- > 1e-20 > (1 row) > Should also yield no results: > SELECT ts_rank(to_tsvector('lets eat a fat cat'), ('fat & bat | > rat'::tsquery && 'cat'::tsquery)); > ts_rank > ----------- > 0.0991032 > (1 row) > Is this intended behavior? Don't see what you find surprising about it? ts_rank() is documented as Ranks vectors based on the frequency of their matching lexemes. The first example has one lexeme that matches the query's lexemes, the second has two. It should get a higher ranking. If you want to know whether the tsvector formally matches the query, you should be applying the @@ operator. ts_rank() is not a binary yes/no thing, it's trying to identify stuff that is more or less relevant to the query's terms. At least from the documentation, I'd suspect it pays no attention to the operators in the query. In short: the intended use of ts_rank() is for sorting values that have already passed an @@ match. It's not a substitute for @@. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs