mysql - 为什么 MATCH() 函数没有给出结果?

标签 mysql match match-against against

我正在使用 MySQL 5.5.31 我想使用 MATCH() 和 AGAINST() 函数。为此,我在 phpMyAdmin 中运行以下查询:

CREATE TABLE articles (
       id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
       title VARCHAR(200),
       body TEXT,
       FULLTEXT (title,body)
     ) ENGINE=MyISAM;


INSERT INTO articles (title,body) VALUES
     ('MySQL Tutorial','DBMS stands for DataBase ...'),
     ('How To Use MySQL Well','After you went through a ...'),
     ('Optimizing MySQL','In this tutorial we will show ...'),
     ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
     ('MySQL vs. YourSQL','In the following database comparison ...'),
     ('MySQL Security','When configured properly, MySQL ...');
     ('MySQL table','The database is very large');

为了搜索字符串“数据库”,我运行以下查询:

SELECT * FROM articles
     WHERE MATCH (title,body)
     AGAINST ('database' IN NATURAL LANGUAGE MODE);

它返回了表中包含单词“数据库”的所有三行。但是,当我搜索其他字符串(如“the”)时,它没有返回任何内容。它返回空值。我不明白为什么会这样?此外,如果要搜索的字符串出现在标题列中,则返回 null。 谁能解开我的这两个疑惑?提前致谢。

最佳答案

MySQL 在全文模式下有 4 个字符的最小搜索限制。

http://dev.mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html

ft_min_word_length 变量可以改变。

这是供将来引用的完整停用词列表。

http://dev.mysql.com/doc/refman/5.5/en/fulltext-stopwords.html

什么是停用词? http://dev.mysql.com/doc/refman/5.1/en/fulltext-natural-language.html

Some words are ignored in full-text searches:

Words in the stopword list are ignored. A stopword is a word such as “the” or “some” that is so common that it is considered to have zero semantic value. There is a built-in stopword list, but it can be overwritten by a user-defined list.

关于mysql - 为什么 MATCH() 函数没有给出结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20541891/

相关文章:

Mysql Match Against query - 在结果中显示匹配的关键字

mysql - SQL从指定类别及其子项中选择所有产品

Mysql查询,范围内的最大值和最小值没有得到正确的输出

javascript - 正则表达式:包括标点符号的字符串匹配

java - 验证单词中给定字母的数量(重复和顺序并不重要)

mysql - 在 MySQL 中为全文搜索添加一个 *(星号)

MySQL全文搜索使用匹配返回错误的结果集

mysql - 通过一个查询从两个表中获取计算结果

php - 如何根据表单选择构建正确的查询?

使用 R 中另一个数据帧的其他匹配 ID 替换数据帧中的值