Skip to content

Instantly share code, notes, and snippets.

View toots's full-sized avatar

Romain Beauxis toots

View GitHub Profile
@toots
toots / tsvector_agg.sql
Created April 4, 2019 18:49 — forked from glittershark/tsvector_agg.sql
Postgresql aggregate function for tsvectors
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,