简体   繁体   English

MySQL-全文搜索

[英]MySQL - Full text search

I'm using a MySQL db with a full-text index of the two fields (name and aliases). 我正在使用带有两个字段(名称和别名)全文索引的MySQL数据库。

It is a videogames database 这是一个电子游戏数据库

codice: codice:

SELECT name,MATCH (name,aliases) AGAINST ('inFamous: Second Son') AS relevance
FROM games_search
ORDER BY relevance DESC;

With this query I get the following results 通过此查询,我得到以下结果

codice: codice:

inFamous 2                     9.150630950927734
inFamous: Second Son           9.150630950927734
inFamous                       8.947185516357422
inFamous: Festival of Blood    8.947185516357422

Why the first two results have the same relevance? 为什么前两个结果具有相同的相关性?

Full text search in MySQL ignores two types of words: stop words and words shorted than some threshhold. MySQL中的全文本搜索会忽略两种类型的单词:停用单词和比阈值短的单词。

You can read the list of stop words here . 您可以在此处阅读停用词列表。 Of particular interest in your case is the word 'second' . 与您的案例特别相关的是'second'一词。

By default, only words with 4 characters or longer are kept for search purposes. 默认情况下,仅保留4个字符或更长的单词用于搜索。 Hence, 'son' is ignored. 因此, 'son'被忽略。 So, your query is equivalent to: 因此,您的查询等效于:

SELECT name, MATCH (name,aliases) AGAINST ('inFamous:') AS relevance
FROM games_search
ORDER BY relevance DESC;

I am not sure why these are higher than the last two. 我不知道为什么这些数字要比最后两个数字高。 I speculate that the relevancy is treating a perfect match (minus stop words and short words) as slightly higher than an imperfect match. 我推测相关性将完全匹配(减去停用词和短词)视为比不完全匹配更高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM