From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Simon Riggs <simon(at)2ndquadrant(dot)com> |
Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Simplifying Text Search |
Date: | 2007-11-14 13:24:43 |
Message-ID: | 200711141324.lAEDOhG22100@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Simon Riggs wrote:
> Better idea:
>
> in-linable function called
>
> create function
> contains(sourceText text, searchText text, config text) returns boolean
> as $$
> to_tsvector(config, sourceText) @@ to_tsquery(config, searchText);
> $$ language sql;
>
> so that
>
> SELECT title
> FROM pgweb
> WHERE contains(body, 'a & b', 'english')
>
> is an indexable, easily readable way of using full text search.
>
> allowing
>
> SELECT to_tsvector('fat cats ate fat rats') @@ to_tsquery('fat & rat');
> ?column?
> ----------
> t
>
> to become
>
> SELECT contains('fat cats ate fat rats', 'fat & rat', 'english');
> ?column?
> ----------
> t
>
> Proposed changes:
> 1. Add function contains()
> 2. Alter docs to show use of contains()
>
> All other @@ features still the same
One advantage to this syntax is that it allows the specification of the
configuration name, which needs a function call to be done with the @@
operator.
However, to access a tsvector column we would need to add another
function that takes a tsvector value. However, the config specification
would apply only to the text column, not the pre-computed tsvector, so
that might be confusing. I think this method could use a function index
but it wouldn't be very clear from the syntax.
The problem I always kept having in clarifying the syntax is that I
could never find anything that covered all common use cases.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
From | Date | Subject | |
---|---|---|---|
Next Message | Zdenek Kotala | 2007-11-14 14:14:45 | Re: Fix pg_dump dependency on postgres.h |
Previous Message | Zeugswetter Andreas ADI SD | 2007-11-14 11:31:05 | Re: How to keep a table in memory? |