我在 boolean 搜索方面遇到问题,首先我认为我的数据库/表有问题,但后来我尝试创建以下包含 1 列和示例值的示例表,结果是相同的,它成功运行了一些单词并且对其他人来说失败了,有什么想法吗?
成功运行的查询:
SELECT * FROM `temp` WHERE (match (txt) against ('develo*' IN BOOLEAN MODE)>0 )
SELECT * FROM `temp` WHERE (match (txt) against ('devel*' IN BOOLEAN MODE)>0 )
SELECT * FROM `temp` WHERE (match (txt) against ('senio*' IN BOOLEAN MODE)>0 )
但是当我尝试对单词“第二”或“第三”进行类似搜索时,它失败了
SELECT * FROM `temp` WHERE (match (txt) against ('secon*' IN BOOLEAN MODE)>0 )
SELECT * FROM `temp` WHERE (match (txt) against ('third*' IN BOOLEAN MODE)>0 )
--- 以下是示例表和值 -----
CREATE TABLE IF NOT EXISTS `temp` (
`txt` varchar(30) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `temp`
--
INSERT INTO `temp` (`txt`) VALUES
('developer'),
('Developer'),
('Developer senior'),
('senior developer'),
('second job'),
('job second'),
('third'),
('third job'),
('job third');
最佳答案
如stopwords list应用在 BOOLEAN MODE 匹配中,单词 second
和 third
会被引擎忽略。
您可以使用自己的停用词列表覆盖默认停用词列表,如here所述:
To override the default stopword list, set the
ft_stopword_file
system variable. [...] The variable value should be the path name of the file containing the stopword list, or the empty string to disable stopword filtering. The server looks for the file in the data directory unless an absolute path name is given to specify a different directory. After changing the value of this variable or the contents of the stopword file, restart the server and rebuild yourFULLTEXT
indexes.
关于mysql - BOOLEAN 搜索 MySQL 不适用于某些单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12898466/