Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 789BF632220 for ; Tue, 31 Aug 2010 18:31:11 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 66688-02 for ; Tue, 31 Aug 2010 21:31:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-vbr15.xs4all.nl (smtp-vbr15.xs4all.nl [194.109.24.35]) by mail.postgresql.org (Postfix) with ESMTP id 128686321A7 for ; Tue, 31 Aug 2010 18:31:03 -0300 (ADT) Received: from webmail.xs4all.nl (dovemail9.xs4all.nl [194.109.26.11]) by smtp-vbr15.xs4all.nl (8.13.8/8.13.8) with ESMTP id o7VLV16K092087 for ; Tue, 31 Aug 2010 23:31:02 +0200 (CEST) (envelope-from er@xs4all.nl) Received: from 156.83.0.242 (SquirrelMail authenticated user er) by webmail.xs4all.nl with HTTP; Tue, 31 Aug 2010 23:31:02 +0200 Message-ID: Date: Tue, 31 Aug 2010 23:31:02 +0200 Subject: prefix search in tsearch From: "Erik Rijkers" To: pgsql-docs@postgresql.org User-Agent: SquirrelMail/1.4.18 MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20100831233102_96595" X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/166 X-Sequence-Number: 5990 ------=_20100831233102_96595 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit [docs from cvs HEAD] I found the text-search documentation a little unclear about 'prefix search'; specifically, the examples do not show that the so-called 'prefix' is first stemmed, before it is used as prefix. For instance, the following can be a little surprising: SELECT to_tsvector( 'postgraduate' ) @@ to_tsquery( 'postgres:*' ); ?column? ---------- t (1 row) Because prefix search is such an important functionality I think this should be better explained, which I hope the attached doc-patch does. (In textsearch.sgml is another mention + example of prefix search, perhaps it should be extended a little there too - which I'm happy to do as well, but I first wanted to see if you agree that it is a little too obscure as it stands) Erik Rijkers ------=_20100831233102_96595 Content-Type: text/x-patch; name="datatype.sgml.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="datatype.sgml.diff" --- doc/src/sgml/datatype.sgml.orig 2010-08-31 22:35:20.000000000 +0200 +++ doc/src/sgml/datatype.sgml 2010-08-31 23:27:51.000000000 +0200 @@ -3842,7 +3842,25 @@ 'super':* This query will match any word in a tsvector that begins - with super. + with super. Note that the 'prefix' term will be stemmed + first, which means that this will match: + +SELECT to_tsvector( 'postgraduate' ) @@ to_tsquery( 'postgres:*' ); + ?column? +---------- + t +(1 row) + + because 'postgres' gets stemmed into 'postgr': + +SELECT to_tsquery('postgres:*'); + to_tsquery +------------ + 'postgr':* +(1 row) + + which then of course also matches 'postgraduate'. + ------=_20100831233102_96595--