Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Trosclair xn

View GitHub Profile
@cpursley
cpursley / full_text_search.sql
Last active Jun 24, 2022
Postgres Full Text Search
View full_text_search.sql
CREATE EXTENSION unaccent;
ALTER TABLE client
ADD COLUMN full_text_search VARCHAR;
-- Do an initial update and apply the UNACCENT function searchable content
UPDATE client
SET full_text_search = tsvector_to_array(to_tsvector('english', UNACCENT(name || ' ' || COALESCE(notes, ' ') || ' ' || COALESCE(location_address, ' '))));
-- Create an AFTER INSERT OR UPDATE trigger (to maintain the column data for inserted/updated rows)