pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Alexander Hill <alex@hill.net.au>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8354: stripped positions can generate nonzero rank in ts_rank_cd
Date: Tue, 11 Feb 2014 10:45:37 -0500
Message-ID: <20140211154537.GA2289@momjian.us> (raw)
In-Reply-To: <CA+KBOKxsaU7Q-Qc6-YV99AY1U_Rb0SbR78Bs5xM6=12PRMKJKA@mail.gmail.com>
References: <E1V59Oo-0007mB-GA@wrigleys.postgresql.org>
	<20140131212251.GQ19957@momjian.us>
	<CA+KBOKxsaU7Q-Qc6-YV99AY1U_Rb0SbR78Bs5xM6=12PRMKJKA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On Fri, Feb  7, 2014 at 02:07:59AM +0800, Alexander Hill wrote:
> Hi Bruce, all,
> 
> I think this can be solved (if it's agreed that it's a bug) in a pretty
> straightforward way: when creating the document representation used in
> calculating cover density rank, we can just skip lexemes with no position
> entirely.
> 
> Fix and tests here: https://github.com/AlexHill/postgres/compare/bug_8354
> 
> As a patch file here: https://github.com/AlexHill/postgres/commit/
> cd522b254d166d569b86803115f0f499864e949b.patch 

OK, great.  I am attaching this patch.  Would this change the contents
of any indexes?  That would be a problem for pg_upgrade.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

tsrank.patch (text/x-diff, 1.7K) download diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c index c9e71c9..bb220d4 100644 --- a/src/backend/utils/adt/tsrank.c +++ b/src/backend/utils/adt/tsrank.c @@ -658,8 +658,8 @@ } else { - dimt = POSNULL.npos; - post = POSNULL.pos; + entry++; + continue; } while (cur + dimt >= len) diff --git a/src/test/regress/expected/tsearch.out b/src/test/regress/expected/tsearch.out index 9341dbe..3bbfb655 100644 --- a/src/test/regress/expected/tsearch.out +++ b/src/test/regress/expected/tsearch.out @@ -596,6 +596,20 @@ S. T. Coleridge (1772-1834) 0.1 (1 row) +SELECT ts_rank_cd(strip(to_tsvector('both stripped')), + to_tsquery('both&stripped')); + ts_rank_cd +------------ + 0 +(1 row) + +SELECT ts_rank_cd(to_tsvector('unstripped') || strip(to_tsvector('stripped')), + to_tsquery('unstripped&stripped')); + ts_rank_cd +------------ + 0 +(1 row) + --headline tests SELECT ts_headline('english', ' Day after day, day after day, diff --git a/src/test/regress/sql/tsearch.sql b/src/test/regress/sql/tsearch.sql index 9fd1207..1f21826 100644 --- a/src/test/regress/sql/tsearch.sql +++ b/src/test/regress/sql/tsearch.sql @@ -165,6 +165,12 @@ Water, water, every where, S. T. Coleridge (1772-1834) '), to_tsquery('english', 'ocean')); +SELECT ts_rank_cd(strip(to_tsvector('both stripped')), + to_tsquery('both&stripped')); + +SELECT ts_rank_cd(to_tsvector('unstripped') || strip(to_tsvector('stripped')), + to_tsquery('unstripped&stripped')); + --headline tests SELECT ts_headline('english', ' Day after day, day after day, -- 1.8.5.1

view thread (12+ messages)  latest in thread

Message-ID: <20140211154537.GA2289@momjian.us>
Permalink:  ../20140211154537.GA2289@momjian.us/
Also on:    postgresql.org/message-id/20140211154537.GA2289@momjian.us

 ·  · 

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: bruce@momjian.us, alex@hill.net.au
  Subject: Re: BUG #8354: stripped positions can generate nonzero rank in ts_rank_cd
  In-Reply-To: <20140211154537.GA2289@momjian.us>
  References: <E1V59Oo-0007mB-GA@wrigleys.postgresql.org> <20140131212251.GQ19957@momjian.us> <CA+KBOKxsaU7Q-Qc6-YV99AY1U_Rb0SbR78Bs5xM6=12PRMKJKA@mail.gmail.com> <20140211154537.GA2289@momjian.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