我正在尝试跨三列创建全文搜索索引,但它没有返回任何结果,即使它看起来应该如此。我已经在具有以下结构和数据的测试表中复制了该问题:
CREATE TABLE IF NOT EXISTS `testtable` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`link` varchar(255) NOT NULL,
`description` text NOT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `title` (`title`,`link`,`description`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
INSERT INTO `testtable` (`id`, `title`, `link`, `description`) VALUES
(1, 'mysql article', 'domain.com/article/1', 'This is an article about MySQL'),
(2, 'some other article', 'domain.com/article/mysql-article', 'This has mysql in the link but not the title'),
(3, 'my super mysql article', 'domain.com/mysql-link', 'the keyword is not in the description'),
(4, 'okay i''m searching for something', 'domain.com', 'and it''s not in the title or description'),
(5, 'mysql article', 'mydomain.com/mysql', 'mysql is definitely written in every field');
这是我正在使用的查询:
select * from `testtable` where MATCH(title, link, description) AGAINST('mysql')
除第 4 行外,短语 mysql 至少出现在所有内容的一列中,而第 5 行的每一列中都有短语 mysql。所以至少它应该返回第 5 行。但它没有返回任何结果。
任何人都可以解释为什么会这样吗?