Re: tsearch2: How to use different configurations for two columns? - Mailing list pgsql-general

From Andrew J. Kopciuch
Subject Re: tsearch2: How to use different configurations for two columns?
Date
Msg-id 200512090935.44264.akopciuch@bddf.ca
Whole thread Raw
In response to Re: tsearch2: How to use different configurations for two columns?  ("Andrew J. Kopciuch" <akopciuch@bddf.ca>)
Responses Re: tsearch2: How to use different configurations for two
Re: tsearch2: How to use different configurations for two
List 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

pgsql-general by date:

Previous
From: William
Date:
Subject: PgSQL 8.1.0 Solaris w/ Sun's cc
Next
From: Luca Pireddu
Date:
Subject: Re: bug or not? Trigger preventing delete causes circumvention