bug in ts_rank_cd - Mailing list pgsql-hackers

From Sushant Sinha
Subject bug in ts_rank_cd
Date
Msg-id 1292938715.2327.9.camel@yoffice
Whole thread Raw
Responses Re: bug in ts_rank_cd  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
MY PREV EMAIL HAD A PROBLEM. Please reply to this one
======================================================

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

pgsql-hackers by date:

Previous
From: Sushant Sinha
Date:
Subject: bug in ts_rank_cd
Next
From: Florian Pflug
Date:
Subject: Re: [FeatureRequest] Base Convert Function