Daniel Cook
Daniel Cook

Reputation: 1043

SQL Thesaurus like behaviour without Full-text Search

My search engine is written using mySQL and ColdFusion, the main part of is where I loop the following (or similar) on each search term separated by spaces.

AND productname REGEXP '(\\b#trim(search)#\\b)'

I'd like to introduce alternatives words, so that when any one of these are searched the rest are included

M43, M4/3, Micro-Four-Thirds, MFT

I could use a separate query to get a list of matching keywords and loop in an OR - but this seemed a little unrefined.

My database is a list of camera product names with little consistency, I tested full-text search but was not happy with the results.

So is there an 'Theasaurus' like option without the need of Full-text search implementation?

Upvotes: 0

Views: 222

Answers (1)

Daniel Cook
Daniel Cook

Reputation: 1043

I added a product keyword field, which I populated with alternative keywords.

My SQL where clause has now loops the terms and compares against the concatenated product name and keywords

 AND concat_ws(' ', productname, productkeywords) REGEXP '(\\b#trim(search)#\\b)' 

Thanks to @SevRoberts for this solution

Upvotes: 0

Related Questions