mysql - BOOLEAN 搜索 MySQL 不适用于某些单词

标签 mysql search boolean

我在 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 匹配中,单词 secondthird 会被引擎忽略。

您可以使用自己的停用词列表覆盖默认停用词列表,如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 your FULLTEXT indexes.

关于mysql - BOOLEAN 搜索 MySQL 不适用于某些单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12898466/

相关文章:

mysql - Django 在 mysql 中选择不同的

algorithm - 检查圆是否适合穿过非量化二维空间中的迷宫

python - 检查列表中至少有一个关键字实例

javascript - 如何在 JavaScript 中打开和关闭灯泡?

MySQL 工作台 6.3 : how should I insert a new column into a specific position (in the middle of the table)

mysql - 如何删除mysql中不重复的行?

MySQL - 昂贵的子查询

search - Angular 全局搜索框

c++ - C++模板中的多步推理器

java - 如果 boolean 数组为 true,则用字符串(多维)填充它