lundi 20 avril 2015

Postgres full-text search with synonyms and near by words

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' || ' '''))));

Now, a notable problem with this search is the word purchase. We can have buy, acquire, obtain as synonyms. For the word "table". We can have chair as near by word. When somebody searches any of these, I need to search products for all of these terms(synonyms and near by word).

From what I've read online, it seems I need to give the synonyms dictionary as input, but I'm not sure how to go about this. I thought postgresql supports synonyms search without any synonyms dictionary as input by developers and postgresql provides the synonyms dictionary may be does not have all english words but at least some basic of them. It is quite difficult for developers to give synonyms dictionary

Refer link for synonyms: http://ift.tt/1j1fpWr

Aucun commentaire:

Enregistrer un commentaire