我正在尝试跨三列创建全文搜索索引,但即使看起来应该也没有返回任何结果。我在测试表中使用以下结构和数据复制了问题:
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')
短语mysql出现在除第4行之外的所有内容中的至少一列中,而第5行在每一列中都有短语mysql。所以至少它应该返回第5行。但它没有返回任何结果。
有人可以解释为什么会这样吗?