简体   繁体   English

为什么这2个MySQL查询返回不同的结果

[英]Why do these 2 MySQL queries return different results

I'm running a MySQL query to search a DB of jobs. 我正在运行一个MySQL查询来搜索作业数据库。 I'm using MATCH and AGAINST to be able to order results be relevance. 我正在使用MATCH和AGAINST来确定相关的结果。 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

which as I understand will default to natural language mode, but returns 0 results, whereas: 据我了解,它将默认为自然语言模式,但返回0个结果,而:

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

returns 4 results as expected, but the relevance is always 1, so ordering by relevance isn't actually possible? 会按预期返回4个结果,但相关性始终为1,因此实际上不可能按相关性排序吗?

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 |

Basically, why is natural language mode returning 0 results? 基本上,自然语言模式为什么返回0结果?

From the MySQL documentation for natural language search: 从MySQL文档进行自然语言搜索:

In addition, words that are present in 50% or more of the rows are considered common and do not match. 另外,出现在50%或更多行中的单词被认为是通用的,并且不匹配。

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

It looks like your sample data exceeds that 50% match rate. 您的样本数据似乎超过了50%的匹配率。

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

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