I want to build a tsvector based on the id (1-111.1x) and the name fields of my row, all from a trigger and with tsvector_update_trigger(tsv, 'pg_catalog.german', id, name).
But my id ends up cut off like '-111.1' instead of '1-111.1x'.
Is there a way to customize the conversion, so that the id field is being retained (or to apply certain operations like lower()), all while the name field is properly converted?
Something like this (which doesn't work, as setweight expects a tsvector)?
CREATE FUNCTION tsv_trigger() RETURNS trigger AS $$
begin
new.tsv :=
setweight(new.id, 'A') ||
setweight(to_tsvector('pg_catalog.german', coalesce(new.name,'')), 'D');
return new;
end
$$ LANGUAGE plpgsql;
CREATE TRIGGER TS_tsv
BEFORE INSERT OR UPDATE ON "model"
FOR EACH ROW EXECUTE PROCEDURE
tsv_trigger();
Thanks!