Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 0A5AF1337BD4 for ; Fri, 18 Feb 2011 23:40:35 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 38979-10 for ; Sat, 19 Feb 2011 03:40:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from momjian.us (momjian.us [70.90.9.53]) by mail.postgresql.org (Postfix) with ESMTP id F0D8D1336FA7 for ; Fri, 18 Feb 2011 23:40:26 -0400 (AST) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p1J3eEj21966; Fri, 18 Feb 2011 22:40:14 -0500 (EST) From: Bruce Momjian Message-Id: <201102190340.p1J3eEj21966@momjian.us> Subject: Re: prefix search in tsearch In-Reply-To: To: Oleg Bartunov Date: Fri, 18 Feb 2011 22:40:14 -0500 (EST) CC: Erik Rijkers , pgsql-docs@postgresql.org X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ELM1298086814-11851-1_" Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.361 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FSL_RU_URL=2.271, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/60 X-Sequence-Number: 6408 --ELM1298086814-11851-1_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" I applied a modified documentation patch (attached) that includes Oleg's suggestions. --------------------------------------------------------------------------- Oleg Bartunov wrote: > Erik, > > I think it'd be more clear if you say not 'stemmed', but processed in > according to configuration. Here is an example: > > $SHAREDIR/tsearch_data/my_synonyms.syn contains one line: > one 1 > > > CREATE TEXT SEARCH DICTIONARY my_synonym ( > TEMPLATE = synonym, > SYNONYMS = my_synonyms > ); > > ALTER TEXT SEARCH CONFIGURATION english > ALTER MAPPING FOR asciiword > WITH my_synonym, english_stem; > > > test=# select 'one'::tsvector @@ to_tsquery('english','one:*'); > ?column? > ---------- > f > (1 row) > > because 'one' was processed by my_synonym dictionary. > > test=# select ts_debug('english','one'); > ts_debug > ------------------------------------------------------------------------------ > (asciiword,"Word, all ASCII",one,"{my_synonym,english_stem}",my_synonym,{1}) > (1 row) > > > > On Tue, 31 Aug 2010, Erik Rijkers wrote: > > > [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 > > > > Regards, > Oleg > _____________________________________________________________ > Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru), > Sternberg Astronomical Institute, Moscow University, Russia > Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ > phone: +007(495)939-16-83, +007(495)939-23-83 > > -- > Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-docs -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + --ELM1298086814-11851-1_ Content-Transfer-Encoding: 7bit Content-Type: text/x-diff Content-Disposition: inline; filename="/rtmp/ts.diff" diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 2bf411d..10f0e59 100644 *** a/doc/src/sgml/datatype.sgml --- b/doc/src/sgml/datatype.sgml *************** SELECT 'super:*'::tsquery; *** 3847,3853 **** 'super':* This query will match any word in a tsvector that begins ! with super. --- 3847,3874 ---- 'super':* This query will match any word in a tsvector that begins ! with super. ! ! ! ! Note that text search configuration processing happens before ! comparisons, which means this comparison returns true: ! ! SELECT to_tsvector( 'postgraduate' ) @@ to_tsquery( 'postgres:*' ); ! ?column? ! ---------- ! t ! (1 row) ! ! because postgres gets stemmed to postgr: ! ! SELECT to_tsquery('postgres:*'); ! to_tsquery ! ------------ ! 'postgr':* ! (1 row) ! ! which then matches postgraduate. --ELM1298086814-11851-1_--