0

我正在尝试运行这样的简单查询:

SELECT *, 
MATCH(`col1`,`col2`) 
AGAINST ('some text') AS score
FROM `mytable` ORDER BY score DESC

这总是给出错误:

#1191 - Can't find FULLTEXT index matching the column list

但是,如果我拆分列并执行两个这样的查询:

SELECT *, 
MATCH(`col1`) 
AGAINST ('some text') AS score
FROM `mytable` ORDER BY score DESC

和:

SELECT *, 
MATCH(`col2`) 
AGAINST ('some text') AS score
FROM `mytable` ORDER BY score DESC

然后就可以了。为什么我不能同时匹配两列?我在手册上看到一个例子,几乎完全一样是这样的:

mysql> SELECT id, body, MATCH (title,body) AGAINST
    -> ('Security implications of running MySQL as root') AS score
    -> FROM articles WHERE MATCH (title,body) AGAINST
    -> ('Security implications of running MySQL as root');
4

2 回答 2

3

#1191 - Can't find FULLTEXT index matching the column list

您需要在两列上同时具有 FULLTEXT 索引。 FULLTEXT (col1,col2)

于 2012-12-30T16:14:30.517 回答
2

您需要有一个与您查询的字段匹配的索引。从文档

MATCH() 列列表必须与表的某些 FULLTEXT 索引定义中的列列表完全匹配,

于 2012-12-30T16:13:45.367 回答