Mysql 全文搜索仅返回精确匹配
我有以下脚本Mysql 全文搜索仅返回精确匹配,mysql,Mysql,我有以下脚本 select c.id from ".TBL_COUPONS." as c inner join ".TBL_BUSINESS." as b on c.business_id = b.business_id inner join ".TBL_BLOCATION." as l on c.business_id = l.business_id where (match(c.name) against ('$search') or match (b.name,b
select c.id
from ".TBL_COUPONS." as c
inner join ".TBL_BUSINESS." as b
on c.business_id = b.business_id
inner join ".TBL_BLOCATION." as l
on c.business_id = l.business_id
where
(match(c.name) against ('$search')
or
match (b.name,b.category,b.subcat) against ('$search'))
and l.zip = '$zip'
为什么这只会返回精确的匹配?例如,如果我搜索锁匠,什么都不会出现。
但如果我搜索锁匠,我会得到两个结果。(两个搜索都包括$zip='75061')您的表可以吗?这就是全文匹配的工作方式。它不知道复数,并且匹配整个单词。这个问题不时被提及。有时,当您看到生成的建议“您的意思是……”时,这是一个试图解决这个确切问题的页面。一种方法是用通配符替换最后几个字符,并以布尔模式进行匹配() 搜索词“locksmith”在php中应该改为“locksmith*”,您的代码应该是这样的
match(c.name) against ('$search' IN BOOLEAN MODE)
出于一般目的,您应该从原始搜索词中删除“s”、“ed”、“ing”等,并在末尾添加通配符* 拉丁语1是多字节字符集吗?我应该使用LIKE吗?我需要变种。