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

时间:2013-12-12 11:10:20

标签: 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');

为了搜索字符串'database',我运行以下查询:

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

它返回包含单词'database'的表中的所有三行。但是当我搜索其他类似“the”的字符串时,它并没有给我任何回报。它返回null。我不明白为什么会这样?此外,如果要搜索的字符串出现在标题列中,则返回null。 请问有人清楚我的这两个疑惑吗?提前谢谢。

2 个答案:

答案 0 :(得分:1)

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

  

全文搜索中会忽略某些字词:

     

禁用词列表中的单词将被忽略。禁用词是一个单词,如   “the”或“some”是如此常见,以至于它被认为是零   语义价值。有一个内置的禁用词列表,但它可以   被用户定义的列表覆盖。

答案 1 :(得分:0)

选中此Fine-Tuning MySQL Full-Text Search.

请参阅此链接。此链接可能会对您https://stackoverflow.com/a/3080200/2567813

有所帮助