使用FREETEXTTABLE给列赋予优先权/权重 [英] Giving precedence/weight to a column using FREETEXTTABLE

查看:106
本文介绍了使用FREETEXTTABLE给列赋予优先权/权重的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL Server全文搜索,使用关键字FREETEXTTABLE返回基于几列结果的表,搜索关键字。

I am using SQL Server Full Text Search, with the keyword FREETEXTTABLE to return a table of results based on a few columns, searching for a keyword.

现在我有两个我正在寻找的主要列,标题和说明,我想优先考虑标题列,因为这很可能会有我的结果,但Description也可能包含结果,但我希望它为Title中的单词赋予优先权说明(但我不想使用CONTAINSTABLE,因为这太具体)。有没有办法使用FREETEXTTABLE给列权重/优先级?

Now I have 2 main columns that I am searching on, Title and Description, I want to give precedence to the Title column as this will most likely have my results but Description might contain results too but I want it to give precedence for a word in Title over Description (but I don't want to use CONTAINSTABLE as this is too specific). Is there a way to give columns weights/precedence using FREETEXTTABLE?

推荐答案

您需要使用2个查询和联合,提供你自己的重量,如下所示:

You'll need to use 2 queries with a union, providing a 'weight' of your own, something like this:

select  [key], sum(rnk) as weightRank
from
        (
            select Rank * 2.0 as rnk, [key] from freetexttable(tableName,Title,'free text string')
            union all
            select Rank * 1.0 as rnk, [key] from freetexttable(tableName,Description,'free text string')
        ) as t
group by [key]

这篇关于使用FREETEXTTABLE给列赋予优先权/权重的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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