-- Fix search trigger to use 'simple' instead of 'polish'
CREATE OR REPLACE FUNCTION companies_search_trigger() RETURNS trigger AS $$
BEGIN
    NEW.search_vector :=
        setweight(to_tsvector('simple', COALESCE(NEW.name, '')), 'A') ||
        setweight(to_tsvector('simple', COALESCE(NEW.description_short, '')), 'B') ||
        setweight(to_tsvector('simple', COALESCE(NEW.description_full, '')), 'C');
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER tsvector_update BEFORE INSERT OR UPDATE
ON companies FOR EACH ROW EXECUTE FUNCTION companies_search_trigger();
