1

我在使用 sql 全文索引时遇到了一个奇怪的问题。基本上我正在搜索一个用于存放电子邮件地址的列。对于我测试的所有情况,似乎都按预期工作,除了一个!

SELECT *
FROM Table
WHERE CONTAINS(Email, '"email@me.com"') 

对于某个电子邮件地址,它完全忽略了上面的“电子邮件”部分,而是在做

SELECT *
FROM Table
WHERE CONTAINS(Email, '@me.com') 

只有一个案例我能发现这种情况正在发生。我重新填充了索引,但没有任何乐趣。还重建了目录。

有任何想法吗??

编辑: 我不能将某人的电子邮件地址放在公共网站上,所以我会给出更合适的例子。导致问题的原因是以下形式:

a.b.c@somedomain.net.au

当我做

WHERE CONTAINS(Email, "'a.b.c@somedomain.net.au"')

返回的匹配行都是 form .*@somedomain.net.au。即它忽略了a.b.c部分。

4

1 回答 1

2

Full stops are treated as noise words (or stopwords) in a fulltext index, you can find a list of the excluded characters by checking the system stopwords:

SELECT * FROM sys.fulltext_system_stopwords WHERE language_id = 2057 --this is the lang Id for British English (change accordingly)

So your email address which is "a.b.c@somedomain.net.au" is actually treated as "a b c@somedomain.net.au" and in this particular case as individual letters are also excluded from the index you end up searching on "@somedomain.net.au"

You really have two choices, you can either replace the character you want to include before indexing (so replace the special characters with a match tag) or you remove the words/character you which to include from the Full Text Stoplist.

NT// If you choose the latter I would be careful as this can bloat your index significantly.

Here are some links that should help you :

Configure and Manage Stopwords and Stoplists for Full-Text Search

Create Full Text Stoplists

于 2012-12-18T15:15:09.283 回答