BUG #16235: ts_rank ignores match and only considers lower weighted vector

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: dominik(dot)giger(at)gmail(dot)com
Subject: BUG #16235: ts_rank ignores match and only considers lower weighted vector
Date: 2020-01-27 20:04:26
Message-ID: 16235-2dad73572326cfab@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16235
Logged by: Dominik Giger
Email address: dominik(dot)giger(at)gmail(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Munro 2020-01-27 22:06:17 Re: BUG #16234: LDAP Query
Previous Message Tom Lane 2020-01-27 15:31:44 Re: BUG #16223: Performance regression between 11.6 and 12.1 in an SQL query with a recursive CTE based on function