Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CREATE FUNCTION comment_text_search_trigger() RETURNS trigger AS $$
new.tsv_comment_text :=
setweight(to_tsvector(coalesce(new.story_title,'')), 'A') ||
setweight(to_tsvector(coalesce(new.comment_text,'')), 'B');
return new;
$$ LANGUAGE plpgsql;
/* Trigger on update */
CREATE TRIGGER tsvector_comment_text_update BEFORE INSERT OR UPDATE
ON comments FOR EACH ROW EXECUTE PROCEDURE comment_text_search_trigger();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment