MySQL匹配不正常工作

时间:2011-10-12 00:41:03

标签: mysql

CREATE TABLE `channels` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(30) DEFAULT NULL,
  `description` text,
  `tagline` varchar(50) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `image` varchar(50) DEFAULT NULL,
  `user_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `index_channels_user` (`user_id`),
  FULLTEXT KEY `description` (`description`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;


INSERT INTO 
 `channels` (`id`, `name`, `description`, `tagline`, `created_at`, `image`, `user_id`)
VALUES
 (1, 'sdsd', 'Hello world!', 'dsdsd', '2011-10-09 11:31:59', NULL, 1);


SELECT
  c.id, c.name
FROM channels c
WHERE 
  MATCH(c.description) AGAINST ('Hell' IN BOOLEAN MODE)

我得到0个结果,为什么?

2 个答案:

答案 0 :(得分:2)

Yup @Ben有一点,导致此问题的停用词

尝试阅读这些

http://bugs.mysql.com/bug.php?id=19583

的全文布尔模式搜索停用词问题

http://www.nivas.hr/blog/2009/09/15/how-to-disable-mysql-fulltext-stopwords/

对这些问题的替代解决方法

答案 1 :(得分:0)

您插入的数据不包含“地狱”一词。 试试这个:

SELECT
  c.id, c.name
FROM channels c
WHERE 
  MATCH(c.description) AGAINST ('Hell*' IN BOOLEAN MODE)