I noticed that searches for a particular word wasn't working on our user search, I've narrowed the problem down to this small example.
If you create a test table like this:
CREATE TABLE `names` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
insert into `names`(`id`,`name`) values (1,'Joseph');
insert into `names`(`id`,`name`) values (2,'Dick');
insert into `names`(`id`,`name`) values (3,'Rather');
insert into `names`(`id`,`name`) values (4,'Steven');
insert into `names`(`id`,`name`) values (5,'Anna');
And perform this search:
SELECT * FROM `names` WHERE MATCH(NAME) AGAINST ('+rather* ' IN BOOLEAN MODE);
You will see that there are no results. However substituting 'rather' for any of the other names in the tabl开发者_如何学JAVAe works fine... What's wrong with 'Rather'???
It's mysql version 5.5.8.
Any help greatly appreciated... I really have no idea on this one!!
Thanks.
rather
is a MySQL stopword. You cannot full text search for it by default.
To work around that, you can disable stopwords by setting the ft_stopword_file system variable to the empty string.
'Rather' is the stopword for full text search in BOOLEAN mode for MySql
for more details you can see the following links http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html http://dev.mysql.com/doc/refman/5.5/en/fulltext-stopwords.html
apparently you didnt create fulltext index
check this:
http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html
精彩评论