I have a database of products which I do a full-text search on using pg_search Gem. The query looks something like this:
SELECT "products".* FROM "products" WHERE (((to_tsvector('english', coalesce("products"."description"::TEXT, ''))) @@(to_tsquery('english', ''' ' || 'purchase' || ' '''))));
As I am doing a Full-text search, I want to add the search functionality for following
- Synonyms search eg. words purchase, buy, acquire, obtain
- Near By words eg. words (table, chair) or (pen, Pencil, Eraser)
- Spelling mistake
Now, a notable problem with this search is, when somebody searches any of these, I need to search products for all of these terms(synonyms and near by word and spelling mistake).
But it seems we need to give the synonyms dictionary as input to have this kind of search functionality. How to add custom dictionary to PostgreSQL? Even if we manage to add synonyms dictionary to postgresql, How can we add this to my AWS RDS (Amazon RDS for PostgreSQL) database?
Refer link for synonyms: http://shisaa.jp/postset/postgresql-full-text-search-part-2.html