On AWS RDS Postgres, how to have dictionaries and unaccented full-text search? On AWS RDS Postgres, how to have dictionaries and unaccented full-text search? postgresql postgresql

On AWS RDS Postgres, how to have dictionaries and unaccented full-text search?


You can change by altering the role parameters in the database like:

ALTER ROLE [role] IN DATABASE [database]    SET default_text_search_config TO 'pg_catalog.english';


Don't rely on the default_text_search_config.

Instead, create your own text search configuration as you do in #5. Then use the two-argument form of to_tsvector to specify that custom text search configuration instead of the default:

SELECT * from mytable where to_tsvector('myconfig', description)     @@ to_tsquery('cat & dog')

An additional benefit of the two-argument version of to_tsvector is that it allows you to use an "expression index" to power text search, rather than a separate tsvector column in your table:

CREATE_INDEX mytable_tsv_idx ON mytable USING GIN    (to_tsvector('myconfig', description));-- This query will use the indexSELECT * from mytable WHERE to_tsvector('myconfig', description)     @@ to_tsquery('cat & dog');-- This query, despite setting the default config, -- will not use the expression index.SET default_text_search_config = 'myconfig';SELECT * from mytable WHERE to_tsvector(description)     @@ to_tsquery('cat & dog');

https://www.postgresql.org/docs/9.5/static/textsearch-tables.html#TEXTSEARCH-TABLES-INDEX