Thread: Basic problem installing TSearch2 (full text search)
Hi all,
I've installed TSearch2 with some success- my table now contains a tsvector field that's indexed and I can run full text queries.
However, the trigger that I created to update the full text index when a row is modified appears to cause a problem. It's returning the error when I run an Update statement:
could not find tsearch config by locale
The general intro doc to TSearch2 covers this error and explains how to fix it. (http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/tsearch-V2-intro.html) I thought that I changed the config properly but obviously I'm missing something. The steps I followed and the values in the system tables I updated are listed below. I'd appreciate any input!
/* add indexed text field and trigger */
UPDATE log SET fti_notes = to_tsvector('default', notes);
CREATE INDEX log_fti_notes_index ON log USING gist(fti_notes);
vacuum analyze log;
CREATE TRIGGER trg_log_update_tsvector BEFORE UPDATE OR INSERT ON log
FOR EACH ROW EXECUTE PROCEDURE tsearch2(fti_notes, notes);
/* update configuration file */
SHOW server_encoding;
UPDATE log SET fti_notes = to_tsvector('default', notes);
CREATE INDEX log_fti_notes_index ON log USING gist(fti_notes);
vacuum analyze log;
CREATE TRIGGER trg_log_update_tsvector BEFORE UPDATE OR INSERT ON log
FOR EACH ROW EXECUTE PROCEDURE tsearch2(fti_notes, notes);
/* update configuration file */
SHOW server_encoding;
/* above command displays: SQL_ASCII */
update pg_ts_cfg set locale = 'SQL_ASCII' where ts_name = 'default'
SELECT * from pg_ts_cfg
/* above Select returns the following */
ts_name prs_name locale
default default SQL_ASCII
/* now test tsearch. Select statements work! however, update statement with associated trigger fails /*
update log set notes = 'Evergreen in San Jose is a nice place.' where log_id = 529
/* returns error message: could not find tsearch config by locale */