我有一个名为“j_diary_all”的表:
CREATE TABLE `j_diary_all` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`post_type` varchar(1) NOT NULL DEFAULT 'A',
`post_date` date NOT NULL DEFAULT '0000-00-00',
`post_content` longtext NOT NULL,
`post_entry_date` datetime DEFAULT NULL,
`post_cat_id` int(11) DEFAULT NULL,
`post_update_date` datetime DEFAULT NULL,
`post_upd_flag` int(1) DEFAULT '0',
`post_match` int(1) unsigned DEFAULT '0',
`bikes_tmp_ref` int(5) DEFAULT '0',
`bikes_diary_entry` int(5) DEFAULT '0',
`post_label` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ID`),
FULLTEXT KEY `post_content` (`post_content`)
) ENGINE=MyISAM AUTO_INCREMENT=8579 DEFAULT CHARSET=utf8
它在“post_content”字段中包含一个FULLTEXT索引,该表包含8,091行。
如果我运行这些SQL:
SELECT id, post_content, post_date FROM j_diary_all WHERE MATCH(post_content) AGAINST ('kids' IN BOOLEAN MODE);
SELECT id, post_content, post_date FROM j_diary_all WHERE MATCH(post_content) AGAINST ('kids');
SELECT id, post_content, post_date FROM j_diary_all WHERE post_content LIKE '%kids%';
它们都返回3,186行(总计= 8,091行)。
我无法理解为什么:
SELECT id, post_content, post_date FROM j_diary_all WHERE post_content LIKE '%said%';
返回358行,而这些行都不返回任何行:
SELECT id, post_content, post_date FROM j_diary_all WHERE MATCH(post_content) AGAINST ('said' IN BOOLEAN MODE);
SELECT id, post_content, post_date FROM j_diary_all WHERE MATCH(post_content) AGAINST ('said');
我知道使用MySQL FULLTEXT索引的50%规则 - 我认为使用“IN BOOLEAN MODE”可以解决这个问题。但是,我不明白为什么FULLTEXT搜索都没有返回任何记录。
我检查了“ft%”MySQL变量,如果相关的话:
SHOW VARIABLES LIKE 'ft_%';
Variable_name Value
------------------------ ----------------
ft_boolean_syntax + -><()~*:""&|
ft_max_word_len 84
ft_min_word_len 4
ft_query_expansion_limit 20
ft_stopword_file (built-in)
我尝试过“说”的变体:
SELECT id, post_content, post_date FROM j_diary_all WHERE MATCH(post_content) AGAINST ('+said*' IN BOOLEAN MODE);
SELECT id, post_content, post_date FROM j_diary_all WHERE MATCH(post_content) AGAINST ('+said*');
答案 0 :(得分:0)
said
是MyISAM所谓的禁用词,请参阅Full-Text Stopwords(这些词在文本中应该如此常见,以至于它们不包含在索引中)。
要覆盖MyISAM表的默认禁用词列表,请设置ft_stopword_file系统变量。