SQL Server自由文本匹配 - 我如何按相关性排序 [英] SQL Server Freetext match - how do I sort by relevance

查看:196
本文介绍了SQL Server自由文本匹配 - 我如何按相关性排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过自由文本匹配的相关性在SQL Server 2005中排序结果?在MySQL中,你可以在ORDER BY部分使用(大致相当的)MATCH函数,但是我还没有在SQL Server中找到任何等价的东西。



MySQL文档


对于表中的每一行,MATCH()返回一个相关性值;也就是说,搜索字符串与MATCH()列表中列出的列中该行文本之间的相似性度量值。

因此,例如,您可以按照投票数量,然后是相关性排序,最后按创建日期排序。这是可以完成的事情,还是我坚持只返回匹配的值而不具有这种排序能力? 解决方案

如果您使用的是 FREETEXTTABLE ,那么它会返回一个列名 Rank ,所以 / code>应该可以工作。我不知道其他自由文本搜索方法是否也返回这个值或不。你可以试试。


Is it possible to order results in SQL Server 2005 by the relevance of a freetext match? In MySQL you can use the (roughly equivalent) MATCH function in the ORDER BY section, but I haven't found any equivalence in SQL Server.

From the MySQL docs:

For each row in the table, MATCH() returns a relevance value; that is, a similarity measure between the search string and the text in that row in the columns named in the MATCH() list.

So for example you could order by the number of votes, then this relevance, and finally by a creation date. Is this something that can be done, or am I stuck with just returning the matching values and not having this ordering ability?

解决方案

If you are using FREETEXTTABLE then it returns a column name Rank, so order by Rank should work. I don't know if other freetext search methods are also returning this value or not. You can have a try.

这篇关于SQL Server自由文本匹配 - 我如何按相关性排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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