如何根据单词出现次数排序查询结果

时间:2019-07-04 06:22:40

标签: sql-server full-text-search

我有一个产品表,想在 Tag 列上进行搜索,结果必须按单词出现的次数进行排序。

ID | Tag                            
---------------------------------------    
1  | LG television                      
2  | BOSCH vacuum cleaner 55 mm         
3  | SONY home theater 55 watt      
---------------------------------------

要搜索的字符串: LG 55真空影院之家

所需结果:

1. SONY home theater 55 watt (contains three words: 55,theater,home)
2. BOSCH vacuum cleaner 55 mm (contains two words: 55,vacuum)
3. LG television (contains one word: LG)

Find string according to words count中有一个使用 Like 且非常的解决方案。

我想通过全文搜索

实施它

更新:我尝试了以下解决方案,但结果不正确

SELECT ft.[Rank], p.Tag
FROM tblProducts AS p
       INNER JOIN FREETEXTTABLE(tblProducts, Tag, 'LG 55 vacuum theater home') AS ft
                  ON ft.[Key] = p.ProductID
ORDER BY ft.[Rank] DESC;

0 个答案:

没有答案