I'm interesting in applying an index for querying across multiple columns using Postgres full text search.
According to the docs, I could apply a multi-column index like so:
CREATE INDEX pgweb_idx ON pgweb USING GIN (to_tsvector('english', title || ' ' || body)); but I'm confused as to when this index would actually be used. Would the to_tsvector function used in the WHERE clause have to be in precisely the same format as what was used in the index?
SELECT title FROM pgweb WHERE to_tsvector(title || ' ' || body) @@ to_tsquery('something') Would the following queries still make use of the index?:
SELECT title FROM pgweb WHERE to_tsvector(coalesce(title,'') || ' ' || coalesce(body,'')) @@ to_tsquery('something') SELECT title FROM pgweb WHERE to_tsvector(body) @@ to_tsquery('something')