Noise Words in Sql Server 2005 Full Text Search

后端 未结 2 1052
栀梦
栀梦 2021-01-03 08:27

I am attempting to use a full text search over a series of names in my database. This is my first attempt at using full text search. Currently I take the search string enter

2条回答
  •  离开以前
    2021-01-03 08:57

    Here's a working function. The file noiseENU.txt is copied as-is from \Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\FTData .

        Public Function StripNoiseWords(ByVal s As String) As String
            Dim NoiseWords As String = ReadFile("/Standard/Core/Config/noiseENU.txt").Trim
            Dim NoiseWordsRegex As String = Regex.Replace(NoiseWords, "\s+", "|") ' about|after|all|also etc.
            NoiseWordsRegex = String.Format("\s?\b(?:{0})\b\s?", NoiseWordsRegex)
            Dim Result As String = Regex.Replace(s, NoiseWordsRegex, " ", RegexOptions.IgnoreCase) ' replace each noise word with a space
            Result = Regex.Replace(Result, "\s+", " ") ' eliminate any multiple spaces
            Return Result
        End Function
    

提交回复
热议问题