[原创]SQL SERVER 2005/2008 全文索引介绍 (二)
上接[原创]SQL SERVER 2005/2008 全文索引介绍 (一)
对于例1,这里涉及到全文索引的一个重要概念,干扰词(Noise Words)。
为了精简全文索引,Microsoft SQL Server 提供了一种机制,用来去掉那些经常出现但对搜索没有帮助的词。这些词称为“干扰词”或“终止词”。
如英文中的"a"、"and"和"the"等,中文中的"的"、"了"、"在"等,凭经验就知道这些词对于搜索意义不大。因此将他们排除在全文索引之外。
对于SQL 2005,干扰词存放在$SQL_Server_Install_Path\Microsoft SQL Server\MSSQL.1\MSSQL\FTDATA\ 目录中,每种语言对应一个文件。
对于SQL 2008,干扰词存放在系统表sys.fulltext_stopwords中,可通过下面的语句查看:
SELECT stopword FROM sys.fulltext_stopwords WHERE language_id = 2052 --简体中文--下面是部分结果:/*后因在好它小 --请注意这里已并很我*/
SELECT display_term FROM sys.dm_fts_index_keywords_by_document(DB_ID('TestFT'),OBJECT_ID('TB')) WHERE document_id=2 and column_id = 3 --全文键值为2 第3列/*display_term---------------宁夏固原有位网友给敬爱苍老 --注意这里师写封信END OF FILE*/SELECT special_term,display_term FROM sys.dm_fts_parser('宁夏固原有一位网友给敬爱的苍老师写了一封信',1028,0,0) --繁体中文/*special_term display_term---------------- ----------------------------------------------------------------------------------------------------------------Exact Match 宁Exact Match 夏Exact Match 固Exact Match 原有Noise Word 一Exact Match 位Exact Match 网Exact Match 友Exact Match 给Exact Match 敬Exact Match 爱Noise Word 的Exact Match 苍 --注意这里Exact Match 老Exact Match 师Exact Match 写Noise Word 了Noise Word 一Exact Match 封Exact Match 信(20 行受影响)*/SELECT special_term,display_term FROM sys.dm_fts_parser('宁夏固原有一位网友给敬爱的苍老师写了一封信',2052,0,0) --简体中文/*special_term display_term---------------- ----------------------------------------------------------------------------------------------------------------Exact Match 宁夏Exact Match 固Exact Match 原有Noise Word 一Exact Match 位Exact Match 网友Exact Match 给Exact Match 敬爱Noise Word 的Exact Match 苍老 --注意这里Exact Match 师Exact Match 写Noise Word 了Noise Word 一Exact Match 封Exact Match 信(16 行受影响)*/