为什么这 2 个 MySQL 查询返回不同的结果 [英] Why do these 2 MySQL queries return different results

查看:65
本文介绍了为什么这 2 个 MySQL 查询返回不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 MySQL 查询来搜索工作数据库.我正在使用 MATCH 和 AGAINST 来使结果具有相关性.然而,我很困惑为什么这两个查询返回不同的结果:

I'm running a MySQL query to search a DB of jobs. I'm using MATCH and AGAINST to be able to order results be relevance. I'm confused however as to why these 2 queries return different results:

SELECT SQL_CALC_FOUND_ROWS *, MATCH (`title`) 
            AGAINST ("assistant") 
            AS Relevance 
            FROM jobs2 
            WHERE MATCH (`title`) 
            AGAINST ("assistant") AND date  >= CURDATE() - INTERVAL 28 DAY GROUP BY jobref ORDER BY Relevance DESC LIMIT 0,50

据我所知,默认为自然语言模式,但返回 0 个结果,而:

which as I understand will default to natural language mode, but returns 0 results, whereas:

SELECT SQL_CALC_FOUND_ROWS *, MATCH (`title`) 
            AGAINST ("assistant" IN BOOLEAN MODE) 
            AS Relevance 
            FROM jobs2 
            WHERE MATCH (`title`) 
            AGAINST ("assistant" IN BOOLEAN MODE) AND date  >= CURDATE() - INTERVAL 28 DAY GROUP BY jobref ORDER BY Relevance DESC LIMIT 0,50

按预期返回 4 个结果,但相关性始终为 1,因此实际上无法按相关性排序?

returns 4 results as expected, but the relevance is always 1, so ordering by relevance isn't actually possible?

我的数据库有以下测试作业:

my DB has these jobs for testing:

|date               |title                                                          |jobref|

|2016-04-08 07:21:19|Assistant Management Accountant                                |12345 |
|2016-04-08 07:21:19|Assistant Accountant                                           |12346 |
|2016-04-08 07:19:15|Assistant Finance Manager                                      |12347 |
|2016-04-08 07:20:38|Accounts Assistant / Purchase Ledger Clerk / Accounts Payable  |12348 |

基本上,为什么自然语言模式返回 0 个结果?

Basically, why is natural language mode returning 0 results?

推荐答案

来自用于自然语言搜索的 MySQL 文档:

From the MySQL documentation for natural language search:

此外,出现在 50% 或更多行中的词是被视为常见且不匹配.

In addition, words that are present in 50% or more of the rows are considered common and do not match.

http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html

您的样本数据似乎超过了 50% 的匹配率.

It looks like your sample data exceeds that 50% match rate.

这篇关于为什么这 2 个 MySQL 查询返回不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆