Re: Simplifying Text Search

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Simplifying Text Search
Дата
Msg-id 200711141324.lAEDOhG22100@momjian.us
обсуждение исходный текст
Ответ на Re: Simplifying Text Search  (Simon Riggs <simon@2ndquadrant.com>)
Список 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@momjian.us>        http://momjian.us EnterpriseDB
http://postgres.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Zeugswetter Andreas ADI SD"
Дата:
Сообщение: Re: How to keep a table in memory?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Spinlock backoff algorithm