pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Rijkers <er@xs4all.nl>
To: pgsql-docs@postgresql.org
Subject: prefix search in tsearch
Date: Tue, 31 Aug 2010 23:31:02 +0200
Message-ID: <ac8b2e9843ba8af2c032635f73a854a9.squirrel@webmail.xs4all.nl> (raw)

[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

Attachments:

datatype.sgml.diff (text/x-patch, 815B) download --- 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':* </programlisting> This query will match any word in a <type>tsvector</> that begins - with <quote>super</>. + with <quote>super</>. Note that the 'prefix' term will be stemmed + first, which means that this will match: +<programlisting> +SELECT to_tsvector( 'postgraduate' ) @@ to_tsquery( 'postgres:*' ); + ?column? +---------- + t +(1 row) +</programlisting> + because 'postgres' gets stemmed into 'postgr': +<programlisting> +SELECT to_tsquery('postgres:*'); + to_tsquery +------------ + 'postgr':* +(1 row) +</programlisting> + which then of course also matches 'postgraduate'. + </para> <para>

view thread (4+ messages)  latest in thread

Message-ID: <ac8b2e9843ba8af2c032635f73a854a9.squirrel@webmail.xs4all.nl>
Permalink:  ../ac8b2e9843ba8af2c032635f73a854a9.squirrel@webmail.xs4all.nl/
Also on:    postgresql.org/message-id/ac8b2e9843ba8af2c032635f73a854a9.squirrel@webmail.xs4all.nl

 ·  · 

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-docs@postgresql.org
  Cc: er@xs4all.nl
  Subject: Re: prefix search in tsearch
  In-Reply-To: <ac8b2e9843ba8af2c032635f73a854a9.squirrel@webmail.xs4all.nl>
  References: <ac8b2e9843ba8af2c032635f73a854a9.squirrel@webmail.xs4all.nl>

* 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