我从 Mysql 文档中遵循了这个例子:
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
title VARCHAR(200),
body TEXT,
FULLTEXT (title,body)
);
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 ...');
SELECT *, MATCH ( title, body ) AGAINST ( 'database' ) AS Score
FROM articles
WHERE MATCH (title,body) AGAINST ('database');
+----+-------------------+------------------------------+------------+
| id | title | body | Score |
+----+-------------------+------------------------------+------------+
| 5 | MySQL vs. YourSQL | In the following database... | 0.662664...|
| 1 | MySQL Tutorial | DBMS stands for DataBase ... | 0.655458...|
+----+-------------------+------------------------------+------------+
这可行,但如果我删除所有行,但一个:
DELETE FROM `articles` WHERE id >1
然后选择给出分数 0:
SELECT * , MATCH ( title, body ) AGAINST ( 'database' ) AS Score FROM articles
只剩下一行,所有出现都是 100% 的搜索,超过 50% 的所有内容都被视为停用词。我的猜测是停用词得分为 0。这里还有一个停用词列表(但“数据库”一词不在其中):http: //dev.mysql.com/doc/refman/5.1/en/全文-stopwords.html
从http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html你会发现:
自然语言搜索将搜索字符串解释为自然人类语言中的短语(自由文本中的短语)。没有特殊的运算符。停用词列表适用。此外,出现在 50% 或更多行中的单词被认为是常见的并且不匹配。