为什么MATCH返回整数相关性而不是float

时间:2022-09-19 17:49:35

I've looked into the boolean full text search documentation of mysql, and there is written, that MATCH will return a float value, together with an example. Everywhere else that I found reference to this states the same, MATCH will return a float point by relevance score.

我查看了mysql的布尔全文搜索文档,并且写了,MATCH将返回一个浮点值,并附带一个示例。在我发现的其他任何地方都提到相同的状态,MATCH将通过相关性得分返回浮点数。

But when I run this query

但是当我运行这个查询时

select 
match(j.name) against('banana* strawberr* coconut*' IN BOOLEAN MODE) as score
from juices j
order by score desc

I get either a 0 or a 1.

我得到0或1。

This are some of the lines with a 1 as score:

这是一些得分为1的行:

"Banana and strawberry flavor" 
"Apple and banana juice" 
"Coconuts with pickles"

In my understanding, the "banana and strawberry" line should get a higher score than the other two, since there are two words matching?

根据我的理解,“香蕉和草莓”系列应该得到比其他两个更高的分数,因为有两个单词匹配?

1 个解决方案

#1


0  

I just experienced this on one of my tables, where a different table was providing results as expected. Check to verify your table is not set to MyISAM (only returns 1 on match), you'll want InnoDB to get a float value returned on your matches so you can order by matched rank.

我刚刚在我的一个表上遇到过这种情况,其中一个不同的表正在按预期提供结果。检查以确认您的表未设置为MyISAM(仅在匹配时返回1),您将希望InnoDB获得您的匹配返回的浮点值,以便您可以按匹配的排名进行排序。

#1


0  

I just experienced this on one of my tables, where a different table was providing results as expected. Check to verify your table is not set to MyISAM (only returns 1 on match), you'll want InnoDB to get a float value returned on your matches so you can order by matched rank.

我刚刚在我的一个表上遇到过这种情况,其中一个不同的表正在按预期提供结果。检查以确认您的表未设置为MyISAM(仅在匹配时返回1),您将希望InnoDB获得您的匹配返回的浮点值,以便您可以按匹配的排名进行排序。