简体   繁体   English

SQL Server 2008全文搜索找不到单词吗?

[英]SQL Server 2008 full-text search doesn't find word in words?

In the database I have a field with a .mht file. 在数据库中,我有一个带有.mht文件的字段。 I want to use FTS to search in this document. 我想使用FTS在此文档中进行搜索。 I got this working, but I'm not satisfied with the result. 我得到了这个工作,但是我对结果不满意。 For example (sorry it's in dutch, but I think you get my point) I will use 2 words: zieken and ziekenhuis. 例如(很抱歉,这是荷兰语,但我想您明白我的意思),我将使用两个词:zieken和ziekenhuis。 As you can see, the phrase 'zieken' is in the word 'ziekenhuis'. 如您所见,“ ziekenhuis”一词中包含“ zieken”一词。

When I search on 'ziekenhuis' I get about 20 results. 当我搜索“ ziekenhuis”时,我会得到大约20个结果。 When I search on 'zieken' I get 7 results. 当我搜索“ zieken”时,我得到7个结果。 How is this possible? 这怎么可能? I mean, why doesn't the FTS resturn the minimal results which I get from 'ziekenhuis'? 我的意思是,FTS为什么不退还我从“ ziekenhuis”获得的最低结果?

Here's the query I use: 这是我使用的查询:

SELECT DISTINCT
    d.DocID 'Id', 
    d.Titel,
    (SELECT afbeeldinglokatie FROM tbl_Afbeelding WHERE soort = 'beleid') as Pic, 
    'belDoc' as DocType 
FROM docs d
JOIN kpl_Document_Lokatie dl ON d.DocID = dl.DocID
JOIN HandboekLokaties hb ON dl.LokatieID = hb.LokatieID
WHERE hb.InstellingID = @instellingId
    AND (
          FREETEXT(d.Doel, @searchstring)
          OR FREETEXT(d.Toepassingsgebied, @searchstring)
          OR FREETEXT(d.HtmlDocument, @searchstring)
          OR FREETEXT (d.extraTabblad, @searchstring)
          )
    AND d.StatusID NOT IN( 1, 5)

I would suggest that you look at using the CONTAINS predicate, as opposed to FREETEXT 我建议您考虑使用CONTAINS谓词,而不是FREETEXT

Usage scenarios, including what you wish to achieve, can be found in the examples section of the documentation. 可以在文档的示例部分中找到包括您希望达到的使用场景。

From your description, I believe that you are attempting to perform a "Prefix" search. 根据您的描述,我认为您正在尝试执行“前缀”搜索。 For example: 例如:

USE AdventureWorks;
GO
SELECT Name
FROM Production.Product
WHERE CONTAINS(Name, ' "SearchTerm*" ');
GO

This will provide you a result set containing all words that "contain" the prefix search term. 这将为您提供一个结果集,其中包含“包含”前缀搜索词的所有单词。

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

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