SELECT * FROM `db`
WHERE MATCH (city) AGAINST ('south ban' IN BOOLEAN MODE)
SELECT * FROM 'db'
WHERE city LIKE '%south ban%'
我有2个查询,一个是使用匹配,另一个是LIKE,
当我尝试搜索“南岸”时
如果用户输入南禁止, Match
将不会返回,但Like
将返回结果
如何改善与搜索的匹配?
我做了测试,
(country LIKE '%south%' || state LIKE '%south%' || city LIKE '%south%') &&
(country LIKE '%bank%' || state LIKE '%bank%' || city LIKE '%bank%')
MATCH (country, stateprov, city) AGAINST ('south bank*' IN BOOLEAN MODE)
为3百万行
匹配 - 69,310行 - 2.5秒
LIKE - 67,092行 - 1.87秒
为什么比匹配更快?
答案 0 :(得分:1)
如果你使用不带+的IN BOOLEAN MODE查询,匹配实际上是对每一行进行评级,这需要时间。
从http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html
查看此信息(no operator)
By default (when neither + nor - is specified) the word is optional, but the rows that contain it are rated higher. This mimics the behavior of MATCH() ... AGAINST() without the IN BOOLEAN MODE modifier.