【问题标题】:Why MATCH() function is not giving results?为什么 MATCH() 函数没有给出结果?
【发布时间】:2013-12-12 11:10:20
【问题描述】:

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


    【解决方案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” 很常见以至于它被认为是零 语义价值。有一个内置的停用词列表,但它可以是 被用户定义的列表覆盖。

    【讨论】:

    • 如果是这样的话,我怎么能搜索字符串“数据库”?长度为 8 个字符。
    • 小于 4 不会返回任何东西。
    • 但是我尝试了一个长度超过四个字符的单词(以下),但它仍然是空的。为什么会这样?
    猜你喜欢
    • 2019-05-17
    • 1970-01-01
    • 2020-07-22
    • 1970-01-01
    • 2015-10-07
    • 2023-03-17
    • 2016-03-31
    • 1970-01-01
    相关资源
    最近更新 更多