From: Tom Lane <tgl@sss.pgh.pa.us>
To: bjorn@eventmy.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14552: tsquery converts AND operator into OR when nested inside OR operations
Date: Fri, 17 Feb 2017 20:24:25 -0500
Message-ID: <11187.1487381065@sss.pgh.pa.us> (raw)
In-Reply-To: <20170218003621.6098.76708@wrigleys.postgresql.org>
References: <20170218003621.6098.76708@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
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
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-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, bjorn@eventmy.com
Subject: Re: BUG #14552: tsquery converts AND operator into OR when nested inside OR operations
In-Reply-To: <11187.1487381065@sss.pgh.pa.us>
References: <20170218003621.6098.76708@wrigleys.postgresql.org> <11187.1487381065@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