订购FULLTEXT搜索相关性和其他领域 [英] Ordering FULLTEXT searches on relevance and other fields

查看:211
本文介绍了订购FULLTEXT搜索相关性和其他领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用FULLTEXT自然语言搜索,并且我注意到它会根据相关性自动对结果进行排序。但是,当我开始向ORDER添加内容时,它似乎不再按相关性排序。是否有明确设置相关性排序重要性的方法?

...)在SELECT查询的列部分中,然后您可以通过'score'和任何其他必需的参数明确地进行排序。



例如: p>

  SELECT column_a,column_b,MATCH(...)AGAINST(...)AS分数
FROM
...
ORDER BY得分DESC,column_a DESC

这似乎有点可疑(因为您必须在查询的WHERE部分重复相同的MATCH子句才能进行实际匹配),但它应该完美地工作。 (如果有一种狡猾的方式来替代这些东西,我很想知道,但似乎并没有出现在我使用的最新版本的MySQL中。)


I'm using FULLTEXT natural language search, and I notice that it automatically sorts my results by relevance. However, when I start to add things to ORDER, it seems to no longer sort by relevance. Is there a way to explicitly set the importance of relevance sorting?

解决方案

If you specify the MATCH (...) AGAINST (...) within the column portion of the SELECT query, you can then explicitly order by the 'score' and then any other required parameters.

For example:

SELECT column_a, column_b, MATCH(...) AGAINST (...) AS score
FROM
...
ORDER BY score DESC, column_a DESC

This might seems a bit dubious (as you will have to repeat the same MATCH clause within the WHERE portion of the query to do the actual matching) but it should work perfectly. (If there's a cunning way to alias such things, I'd love to know, but there didn't seem to be in the last version of MySQL I used.)

这篇关于订购FULLTEXT搜索相关性和其他领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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