View full_text_search.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |