I have a table of events
where each event has a title
and description
. Searches should search both columns:
title: Dick(ens) and Jane
description: Meet weekly to discuss classic books!
Given the above, I would like a query of book club
to match.
My index:
CREATE INDEX evsearch_idx on events using gist((title || ' ' || description) gist_trgm_ops)
My query:
SELECT * FROM events WHERE title || ' ' || description ILIKE '%book club%'
I think the problem is that I'm fundamentally misunderstanding how an index works and therefore it's attempting to match the entire string book club
to various three-letter combinations but I'm not sure how to fix this.