Fulltext search incorrectly returning nothing
Hi there
I'm quite an experienced MySQL user, but this one has me stumped. I'm running a fulltext search, using MATCH(), and I'm getting no results despite the phrase being in the table.
This is the query I'm running:
===================================
SELECT
*,
MATCH(`subtitles`) AGAINST ('test') AS '_score'
FROM
(videosubtitles)
WHERE
MATCH(`subtitles`) AGAINST ('test')
ORDER BY
`_score` DESC
LIMIT
10
===================================
This is my table script - as you can see, there is a FULLTEXT index on the 'subtitles' column.
===================================
CREATE TABLE `videosubtitles` (
`subtitleId` int(11) NOT NULL AUTO_INCREMENT,
`subtitles` text,
`videoId` int(11) NOT NULL DEFAULT '0',
`language` varchar(10) NOT NULL DEFAULT 'en',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`subtitleId`),
FULLTEXT KEY `subtitles` (`subtitles`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
INSERT INTO `videosubtitles`(`subtitleId`,`subtitles`,`videoId`,`language`,`created`,`modified`) values (1,'this is a test and it\'s nice',0,'en','2011-07-20 18:17:17','2011-07-21 09:21:53');
===================================
The query itself 'works' (ie, doesn't return any errors), but I'm getting 0 results. If I take out the WHERE part of the query, it obviously returns the row but the '_score' is 0.
Can someone point out where I'm going wrong on this?
Thanks
S