I have a posts
that has a column tags
. I'd like to be able to do full text search across the tags. For VARCHAR
columns I've used:
CREATE INDEX posts_fts_idx ON posts USING gin(to_tsvector('english', coalesce(title, ''));
SELECT "posts".* FROM "posts" WHERE (to_tsvector('english', coalesce(title, '')) @@ (to_tsquery('english', 'ruby')));
However, for character varying[]
the function to_tsvector
does not exist. How can a query be written that will run against each of the tags (ideally matching if any single tag matches)?
Note: I see that it would be pretty easy to do a conversion to a string (array_to_string
) but if possible I'd like to convert each individual tag to a tsvector
.