Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux