pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: dominik.giger@gmail.com
Subject: BUG #16235: ts_rank ignores match and only considers lower weighted vector
Date: Mon, 27 Jan 2020 20:04:26 +0000
Message-ID: <16235-2dad73572326cfab@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16235
Logged by:          Dominik Giger
Email address:      dominik.giger@gmail.com
PostgreSQL version: 12.1
Operating system:   Linux
Description:        

The following query shows the problem:

select ts_rank(doc1, query) as rank_wrong, ts_rank(doc2, query) as
rank_correct
from (select setweight(to_tsvector('simple', 'foo something'), 'A') ||
             setweight(to_tsvector('simple', 'foobar'), 'C')    as doc1,
             setweight(to_tsvector('simple', 'foo something'), 'A') as
doc2,
             to_tsquery('simple', 'foo:* & something')               as
query) as subquery;

Some more explanation:

doc1 looks like this: 
'foo':1A 'foobar':3C 'something':2A

doc2 looks like this:
'foo':1A 'something':2A

Calling ts_rank on both vectors with the same query
'foo':* & 'something'

Expected result: 
ts_rank on doc1 is the same or higher than ts_rank on doc2.

Actual result: 
ts_rank on doc1 is only half of the rank of doc2. ts_rank seems to only
consider the 'foobar' term with lower weight when calculating the rank. The
foo:1A is only considered in doc2.



view thread (3+ messages)  latest in thread

Message-ID: <16235-2dad73572326cfab@postgresql.org>
Permalink:  ../16235-2dad73572326cfab@postgresql.org/
Also on:    postgresql.org/message-id/16235-2dad73572326cfab@postgresql.org

 · 

reply

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: noreply@postgresql.org, dominik.giger@gmail.com
  Subject: Re: BUG #16235: ts_rank ignores match and only considers lower weighted vector
  In-Reply-To: <16235-2dad73572326cfab@postgresql.org>
  References: <16235-2dad73572326cfab@postgresql.org>

* 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