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: Fri, 21 Mar 2014 09:43:23 -0400
Message-ID: <20140321134323.GA1701@momjian.us> (raw)
In-Reply-To: <CA+KBOKxzfHNT96i_Ct6304OEmHUAzY+-sa-OdK7XgSSb-bx3eA@mail.gmail.com>
References: <E1V59Oo-0007mB-GA@wrigleys.postgresql.org>
<20140131212251.GQ19957@momjian.us>
<CA+KBOKxsaU7Q-Qc6-YV99AY1U_Rb0SbR78Bs5xM6=12PRMKJKA@mail.gmail.com>
<20140211154537.GA2289@momjian.us>
<CA+KBOKyWkK-EBoiJ96iPDu-ZA=TTENVOC3u-3gFHvQ0uBzWuVQ@mail.gmail.com>
<20140212143151.GA12551@momjian.us>
<CA+KBOKxzfHNT96i_Ct6304OEmHUAzY+-sa-OdK7XgSSb-bx3eA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Fri, Mar 21, 2014 at 02:29:26PM +0800, Alexander Hill wrote:
> Hi Bruce,
>
> I've just updated the docs for ts_rank_cd in my fork to reflect this change.
> Would be great if that could make it in too.
>
> Patch here: https://github.com/AlexHill/postgres/commit/
> 3e5d86ea23d82b07188192411cdc5c5a5194a5ae.patch
>
> Is there anything else I need to do to make sure this patch ends up in 9.4?
OK, combined patch attached. Is this correct? I keep hoping someone
else will chime in with an opinion on this, but at this point I think
what you have done is clear enough for me to commit for 9.4.
--
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-bugsAttachments:rank.diff (text/x-diff, 3.0K) downloaddiff --git a/doc/src/sgml/textsearch.sgml b/doc/src/sgml/textsearch.sgmlnew file mode 100644index 604e545..a4418ef
*** a/doc/src/sgml/textsearch.sgml
--- b/doc/src/sgml/textsearch.sgml
*************** SELECT plainto_tsquery('english', 'The F
*** 891,897 ****
<para>
This function requires positional information in its input.
Therefore it will not work on <quote>stripped</> <type>tsvector</>
! values — it will always return zero.
</para>
</listitem>
</varlistentry>
--- 891,901 ----
<para>
This function requires positional information in its input.
Therefore it will not work on <quote>stripped</> <type>tsvector</>
! values — it will always return zero. If a <type>tsvector</>
! contains stripped and unstripped lexemes, only the unstripped lexemes
! will be considered. (See <xref linkend="textsearch-manipulate-tsvector">
! for more information about the <function>strip</> function and
! positional information in <type>tsvector</>s.)
</para>
</listitem>
</varlistentry>
diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.cnew file mode 100644index c9e71c9..bb220d4
*** a/src/backend/utils/adt/tsrank.c
--- b/src/backend/utils/adt/tsrank.c
*************** get_docrep(TSVector txt, QueryRepresenta
*** 658,665 ****
}
else
{
! dimt = POSNULL.npos;
! post = POSNULL.pos;
}
while (cur + dimt >= len)
--- 658,665 ----
}
else
{
! entry++;
! continue;
}
while (cur + dimt >= len)
diff --git a/src/test/regress/expected/tsearch.out b/src/test/regress/expected/tsearch.outnew file mode 100644index 9341dbe..d22d345
*** a/src/test/regress/expected/tsearch.out
--- b/src/test/regress/expected/tsearch.out
*************** S. T. Coleridge (1772-1834)
*** 596,601 ****
--- 596,615 ----
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.sqlnew file mode 100644index 9fd1207..fa460cd
*** a/src/test/regress/sql/tsearch.sql
--- b/src/test/regress/sql/tsearch.sql
*************** Water, water, every where,
*** 165,170 ****
--- 165,176 ----
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,
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: <20140321134323.GA1701@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> <CA+KBOKyWkK-EBoiJ96iPDu-ZA=TTENVOC3u-3gFHvQ0uBzWuVQ@mail.gmail.com> <20140212143151.GA12551@momjian.us> <CA+KBOKxzfHNT96i_Ct6304OEmHUAzY+-sa-OdK7XgSSb-bx3eA@mail.gmail.com> <20140321134323.GA1701@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