Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQzjO-0007EJ-5X for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Mar 2014 13:43:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WQzjN-000584-M2 for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Mar 2014 13:43:29 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQzjM-00057x-Ef for pgsql-bugs@postgresql.org; Fri, 21 Mar 2014 13:43:28 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQzjJ-000550-FY for pgsql-bugs@postgresql.org; Fri, 21 Mar 2014 13:43:27 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1WQzjH-0008KM-Vu; Fri, 21 Mar 2014 09:43:23 -0400 Date: Fri, 21 Mar 2014 09:43:23 -0400 From: Bruce Momjian To: Alexander Hill Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #8354: stripped positions can generate nonzero rank in ts_rank_cd Message-ID: <20140321134323.GA1701@momjian.us> References: <20140131212251.GQ19957@momjian.us> <20140211154537.GA2289@momjian.us> <20140212143151.GA12551@momjian.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + --a8Wt8u1KmwUX3Y2C Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="rank.diff" diff --git a/doc/src/sgml/textsearch.sgml b/doc/src/sgml/textsearch.sgml new file mode 100644 index 604e545..a4418ef *** a/doc/src/sgml/textsearch.sgml --- b/doc/src/sgml/textsearch.sgml *************** SELECT plainto_tsquery('english', 'The F *** 891,897 **** This function requires positional information in its input. Therefore it will not work on stripped tsvector ! values — it will always return zero. --- 891,901 ---- This function requires positional information in its input. Therefore it will not work on stripped tsvector ! values — it will always return zero. If a tsvector ! contains stripped and unstripped lexemes, only the unstripped lexemes ! will be considered. (See ! for more information about the strip function and ! positional information in tsvectors.) diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c new file mode 100644 index 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.out new file mode 100644 index 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.sql new file mode 100644 index 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, --a8Wt8u1KmwUX3Y2C Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --a8Wt8u1KmwUX3Y2C--