1 ALTER TABLE question ADD COLUMN tsv tsvector;
3 CREATE OR REPLACE FUNCTION public.create_plpgsql_language ()
6 CREATE LANGUAGE plpgsql;
7 SELECT 'language plpgsql created'::TEXT;
14 WHERE lanname='plpgsql')
16 (SELECT 'language already installed'::TEXT)
18 (SELECT public.create_plpgsql_language())
21 DROP FUNCTION public.create_plpgsql_language ();
23 CREATE OR REPLACE FUNCTION set_question_tsv() RETURNS TRIGGER AS $$
26 setweight(to_tsvector('english', coalesce(new.tagnames,'')), 'A') ||
27 setweight(to_tsvector('english', coalesce(new.title,'')), 'B') ||
28 setweight(to_tsvector('english', coalesce(new.summary,'')), 'C');
33 CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE
34 ON question FOR EACH ROW EXECUTE PROCEDURE set_question_tsv();
36 CREATE INDEX blog_entry_tsv ON blog_entry USING gin(body_tsv);
38 UPDATE question SET title = title;