全文搜索仅返回完全匹配的内容 [英] Fulltext search only returns exact matches

查看:80
本文介绍了全文搜索仅返回完全匹配的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下脚本

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

why would this only return exact matches? For example, if i $search for locksmith nothing comes up. but if i search for locksmiths I'd get two results. (both searches included $zip = '75061')

推荐答案

一种方法是用通配符替换最后几个字符,然后在布尔模式下再次执行MATCH()

One way to do it is to replace the last few characters with a wild card and do the MATCH () AGAINST in boolean mode

应该在php中将搜索词"locksmith"更改为"locksmith *",您的代码将是这样

The search term "locksmith" should be changed in php to "locksmith*" and your code would be something like this

match(c.name) against ('$search' IN BOOLEAN MODE) 

出于一般目的,应从原始搜索词中的单词中删除"s","ed","ing"等,并在末尾添加通配符*.

For general purposes you should remove 's', 'ed', 'ing', etc. from the words in the original search term and add the wild card * to the end.

这篇关于全文搜索仅返回完全匹配的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆