bug in ts_rank_cd

From: Sushant Sinha <sushant354(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: bug in ts_rank_cd
Date: 2010-12-21 13:32:22
Message-ID: 1292938342.2327.8.camel@yoffice
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

There is a bug in ts_rank_cd. It does not correctly give rank when the
query lexeme is the first one in the tsvector.

Example:

select ts_rank_cd(to_tsvector('english', 'abc sdd'),
plainto_tsquery('english', 'abc'));
ts_rank_cd
------------
0

select ts_rank_cd(to_tsvector('english', 'bcg abc sdd'),
plainto_tsquery('english', 'abc'));
ts_rank_cd
------------
0.1

The problem is that the Cover finding algorithm ignores the lexeme at
the 0th position, I have attached a patch which fixes it. After the
patch the result is fine.

select ts_rank_cd(to_tsvector('english', 'abc sdd'), plainto_tsquery(
'english', 'abc'));
ts_rank_cd
------------
0.1

Attachment Content-Type Size
tsrankbugfix.patch text/x-patch 415 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Sushant Sinha 2010-12-21 13:38:35 bug in ts_rank_cd
Previous Message Robert Haas 2010-12-21 12:34:06 Re: SQL/MED - file_fdw