【发布时间】:2014-01-19 23:02:07
【问题描述】:
我正在尝试在 mysql 5.6 上使用 innodb 进行全文搜索,并在 submissions.title, submissions.description 上添加了 FULLTEXT KEY。这是我的show create table submissions:
Create Table: CREATE TABLE `submissions` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`slug` varchar(255) NOT NULL,
`description` mediumtext NOT NULL,
`user_id` int(11) NOT NULL,
`created` datetime NOT NULL,
`type` enum('tip','request') NOT NULL,
`thumbnail` varchar(64) CHARACTER SET latin1 DEFAULT NULL,
`removed` tinyint(1) unsigned NOT NULL DEFAULT '0',
`keywords` varchar(255) NOT NULL,
`ip` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
FULLTEXT KEY `title` (`title`,`description`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8
当我运行以下查询时:
SELECT s.*, MATCH (s.title, s.description) AGAINST ('whatever'), u.username, SUM( sv.up ) helpfulVotes
FROM submissions s
INNER JOIN users u ON s.user_id = u.id
LEFT JOIN submissions_votes sv ON s.id = sv.submission_id
GROUP BY s.id
ORDER BY s.created DESC
LIMIT 0 , 30
我收到#1214 - The used table type doesn't support FULLTEXT indexes 错误。
这是否意味着我需要在我加入的其他字段中添加全文?没有任何意义,因为我没有搜索任何这些字段...
编辑:在我的 prod 机器上进行查询,它的 mysql 版本较旧,而且我的查询是错误的。
正确查询:
SELECT s . * , u.username, SUM( sv.up ) helpfulVotes
FROM submissions s
INNER JOIN users u ON s.user_id = u.id
LEFT JOIN submissions_votes sv ON s.id = sv.submission_id
WHERE MATCH (
s.title, s.description
)
AGAINST (
'whatever'
)
LIMIT 0 , 30;
【问题讨论】:
-
试试不加入吗?
标签: mysql sql full-text-search innodb