Re: Simplifying Text Search

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Simplifying Text Search
Дата
Msg-id 16342.1195077853@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Simplifying Text Search  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> [ replace LIKE with this: ]

> CREATE FUNCTION textlike_ts(text, text) RETURNS boolean
>     RETURNS NULL ON NULL INPUT IMMUTABLE
>     LANGUAGE SQL
>     AS $$ SELECT $1 @@ likepattern_to_tsquery($2) AND $1 #~~# $2; $$;

Cute trick, but as-is this will not make anything go any faster, because
it doesn't expose any opportunities for indexing the @@ operation.
I think what you'd really need is something like

$$ SELECT to_tsvector('english', $1) @@ likepattern_to_tsquery($2) AND $1 #~~# $2; $$;

which will win if there is an expression index on to_tsvector('english',
<textcolumn>).  (You can substitute your preferred configuration of
course, but you don't get to rely on default_text_search_config, because
that would render the expression non-immutable and thus non-indexable.)

This points up the same old notational problem that there is no good
place in the operator notation to mention which text search
configuration you want to use.  Simon's suggestion of a three-parameter
function at least addresses that issue.
        regards, tom lane


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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: psql -f doesn't complain about directories
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Simplifying Text Search