Re: tsearch2: How to use different configurations for two columns?

From: "Andrew J(dot) Kopciuch" <akopciuch(at)bddf(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: tsearch2: How to use different configurations for two columns?
Date: 2005-12-09 16:35:44
Message-ID: 200512090935.44264.akopciuch@bddf.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> You could write a one trigger for the table to handle both.
>

Something like this :

-----

CREATE OR REPLACE FUNCTION multi_tsearch2() RETURNS TRIGGER AS '
DECLARE
BEGIN
NEW.fti_title = to_tsvector(''default'', NEW.title);
NEW.fti_author_list = to_tsvector(''simple'', NEW.author_list);
RETURN NEW;
END;
' LANGUAGE 'PLPGSQL';

CREATE TRIGGER tsvectorupdate_all
BEFORE INSERT OR UPDATE ON publications
FOR EACH ROW
EXECUTE PROCEDURE multi_tsearch2();

----

You can modify the function to be slightly more configurable with parameters
taking the column names, and config names and make it a little more reusable.
You can accomplish what you want though.

Andy

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Luca Pireddu 2005-12-09 16:49:55 Re: bug or not? Trigger preventing delete causes circumvention
Previous Message William 2005-12-09 16:33:35 PgSQL 8.1.0 Solaris w/ Sun's cc