I have following schema:
CREATE TABLE books (
title VARCHAR(255),
subtitle TEXT
);
Adding a generated column without weights is working fine:
ALTER TABLE books ADD COLUMN full_text_search TSVECTOR
GENERATED ALWAYS AS (to_tsvector('english',
coalesce(title, '') ||' '||
coalesce(subtitle, '')
)) STORED; -- ✅ Working
Now I want to add weights and it is not working:
ALTER TABLE books ADD COLUMN full_text_search_weighted TSVECTOR
GENERATED ALWAYS AS (to_tsvector('english',
setweight(coalesce(title, ''), 'A') ||' '||
setweight(coalesce(subtitle, ''), 'B')
)) STORED; -- ❌ Not working
Is there a way to include weights with a generated column in postgres?
Reproduction Link: https://www.db-fiddle.com/f/4jyoMCicNSZpjMt4jFYoz5/1385