简体   繁体   English

SQL 没有全文搜索的词库类行为

[英]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.我的搜索引擎是使用 mySQL 和 ColdFusion 编写的,主要部分是我在每个用空格分隔的搜索词上循环以下(或类似内容)。

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我想介绍替代词,以便在搜索其中任何一个词时包含 rest

M43, M4/3, Micro-Four-Thirds, MFT M43、M4/3、微型四分之三、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.我可以使用单独的查询来获取匹配关键字的列表并在 OR 中循环 - 但这似乎有点不完善。

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?那么是否存在不需要全文搜索实现的类似“Theasaurus”的选项?

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我的 SQL where 子句现在循环术语并与连接的产品名称和关键字进行比较

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

Thanks to @SevRoberts for this solution感谢@SevRoberts 提供此解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM