-
-
Save toots/bc1999bde39ba5a4a38905aeb6ae1801 to your computer and use it in GitHub Desktop.
Postgresql aggregate function for tsvectors
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 OR REPLACE FUNCTION concat_tsvectors(tsv1 tsvector, tsv2 tsvector) | |
RETURNS tsvector AS $$ | |
BEGIN | |
RETURN coalesce(tsv1, to_tsvector('default', '')) | |
|| coalesce(tsv2, to_tsvector('default', '')); | |
END; | |
$$ LANGUAGE plpgsql; | |
CREATE AGGREGATE tsvector_agg ( | |
BASETYPE = tsvector, | |
SFUNC = concat_tsvectors, | |
STYPE = tsvector, | |
INITCOND = '' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment