Created
July 8, 2018 03:50
-
-
Save lettergram/a248b1935fc90a6edfd5065f6e827bd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION comment_text_search_trigger() RETURNS trigger AS $$ | |
begin | |
new.tsv_comment_text := | |
setweight(to_tsvector(coalesce(new.story_title,'')), 'A') || | |
setweight(to_tsvector(coalesce(new.comment_text,'')), 'B'); | |
return new; | |
end | |
$$ 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