简体   繁体   English

SQL Server 2008 R2全文搜索可理解两个单词并具有更好的排名

[英]Sql Server 2008 R2 Full-Text Search understand two words and better ranking

Hi I'm trying to understand Full-Text Search in MS Sql Server. 嗨,我试图了解MS Sql Server中的全文本搜索。

I got a simple search working 我有一个简单的搜索工作

SELECT *
FROM Product
WHERE FREETEXT (*, 'stackoverflow' );

Even got some simple rank working. 甚至得到一些简单的排名。

SELECT
   *
FROM
    Product
    INNER JOIN FREETEXTTABLE ( Product , * , 'stackoverflow' ) ft ON ( Product.ProductNo = ft.[Key] )
ORDER BY
    ft.Rank DESC

My First Question is How do I control the rank more. 我的第一个问题是如何进一步控制排名。 Ex. 防爆。 I want the products , name column to give a higher rank, than the description column if the search word is found there. 如果要在其中找到搜索词,我希望产品名称”列的排名要比描述列更高。 and is it possible to make it search for only part of a word. 并且有可能使它仅搜索单词的一部分。 ex. 恩。

overflow -> return stackoverflow 溢出 ->返回stackoverflow

stack -> return stackoverflow 堆栈 ->返回stackoverflow

My Second Question How do I make it possible to find the correct result when searching after stack overflow in two word. 我的第二个问题如何在两个字的堆栈溢出后进行搜索时如何找到正确的结果。 Since I'm going to have alot of products where some users are going to spell it in two words, when it is correctly spelled in one word. 由于我将拥有很多产品,因此有些用户会用两个单词来拼写,因此正确地用一个单词来拼写。 I got a dictonary installed for my Full Text Catalog, but it don't help with searchword in two words. 我为“全文目录”安装了词典,但使用两个单词搜索词没有帮助。

Product Table 产品表

  • Id ID

  • Name 名称

  • Description 描述

For the first part of your question: You'll need to use 2 queries with a union, providing a 'weight' of your own, something like this... 对于问题的第一部分:您需要使用带有联合的2个查询,提供您自己的“权重”,如下所示...

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]

Second part of your question: 问题的第二部分:

SELECT *
FROM Product
WHERE FREETEXT(*,'FORMSOF(INFLECTIONAL, "stack", "overflow")');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM