-1
SELECT * FROM `db` 
WHERE MATCH (city) AGAINST ('south ban' IN BOOLEAN MODE)

SELECT * FROM 'db'
WHERE city LIKE '%south ban%'

我有 2 个查询,一个是使用 Match against,另一个是 LIKE,

当我尝试搜索“南岸”时

Match如果用户输入south ban则不会返回,但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)

300 万行

匹配 - 69,310 行 - 2.5 秒

LIKE - 67,092 行 - 1.87 秒

为什么 Like 比 match 快?

4

1 回答 1

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.
于 2013-09-15T01:23:00.533 回答