SQL Server 2005.全文搜索。需要同义词库使用NEAR / AND / OR关键字

时间:2010-03-31 10:49:18

标签: sql-server-2005 full-text-search thesaurus

有没有人知道是否可以进行词库搜索 与NEAR或AND / OR关键字一起使用。 以下是我想要运行的查询类型的示例:

    SELECT Title, RANK
            FROM Item INNER JOIN
            CONTAINSTABLE(Item, Title, 'FORMSOF(Thesaurus, "red" NEAR "wine")') AS KEY_TBL
            ON Item.ItemID = KEY_TBL.[KEY]
    ORDER BY RANK DESC

....但我收到错误消息:

在全文搜索条件'FORMSOF(同义词库,“红色”NEAR“wine”)'''NEAR'附近出现语法错误。

2 个答案:

答案 0 :(得分:1)

附近和FormsOf彼此之间不能很好地协作。阅读以下链接 Is it possible to combine NEAR and FORMSOF together in a fulltext search?

使用IsAbout

SELECT   K.RANK, name, Description
FROM      Diagnosis AS C
INNER JOIN
CONTAINSTABLE(diagnosis,name, 'ISABOUT (
FORMSOF(Thesaurus, "red"),
FORMSOF(Thesaurus, "wine"))', 50) AS K
ON C.ID = K.[KEY];
GO

答案 1 :(得分:0)

词库的语法略有不同,您可能正在寻找的是:

SELECT Title, RANK
            FROM Item INNER JOIN
            CONTAINSTABLE(Item, Title, 'FORMSOF(Thesaurus, "red") NEAR FORMSOF(Thesaurus, "wine")') AS KEY_TBL
            ON Item.ItemID = KEY_TBL.[KEY]
    ORDER BY RANK DESC