我正在使用 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/