搜索 'c#' 的全文索引
我有一个表(假设它有一个名为“colLanguage”的列),其中包含技能列表,并在其上定义了全文索引。表中的条目之一是“c#”,但是当我搜索“c#”(使用以下 SQL)时,我没有得到任何结果。
<代码>选择* 从 FREETEXTTABLE(tblList, colLanguage, 'c#')
有人可以帮忙吗?
谢谢 K
I have a table (lets say it has one column called 'colLanguage') that contains a list of skills and has a full text index defined on it. One of the entries in the table is 'c#' but when I search for 'c#' (using the following SQL) I get no results back.
select *
from
FREETEXTTABLE(tblList, colLanguage, 'c#')
Can anyone help?
Thanks
K
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我了解,# 被注册为“断字符”,因此不会添加到索引中。您可以按照本页所述从分词系统列表中取消注册它:
http://msdn.microsoft.com/en-us/library/dd207002.aspx
As far as I understand it, # is registered as a "word breaker" and so is not added to the index. You might be able to deregister it from the list of word breakers as described on this page:
http://msdn.microsoft.com/en-us/library/dd207002.aspx
我的最终解决方案基于“C#”与“c#”的处理方式不同这一事实。当“#”字符之前的字母为大写时,“#”不会被视为断词字符。因此,我必须编写一个脚本来更新全文索引所在的表,以将所有“c#”更改为“C#”(然后我将此脚本作为 sql 作业运行,以确保没有任何情人案例 c#)并确保当搜索“c#”时,我在代码中将其更改为“C#”。
或者,如果您有 SQL2008 并且可以更改 fts 索引的全文语言,则可以将其设置为使用“中性”语言作为索引列的分词系统。 “中性”断字器仅在白色文本上中断。然后更改 fts 命令以指定所使用的语言,例如 select * from FREETEXTTABLE(tblList, colLanguage, 'c#', LANGUAGE 0) 您可以搜索 'c#' 或 'C#',除了重建之外不需要其他任何更改*你索引。
*您可能需要更改数据库实例的“默认全文语言”,我不得不这样做。
My final solution is based on the fact that 'C#' is treated differently to 'c#'. When the letter before the '#' character is upper case the '#' is NOT treated as a word breaking character. Therefore I had to write a script update the table the full-text index was on to change all 'c#' into 'C#' (I then run this script as a sql job to ensure there isn't any lover case c#) and ensure when searching that 'c#' is changed into 'C#' which I did in my code.
Alternately if you have SQL2008 and can change the full-text language for the fts index you can set it to use the 'Neutral' language as the word breaker for the indexed columns. The 'Neutral' word breaker only breaks on white text. Then change your fts command to specify the that as the language used e.g. select * from FREETEXTTABLE(tblList, colLanguage, 'c#', LANGUAGE 0) you can seach for 'c#' or 'C#' with no other changes required* apart from rebuilding you indexes.
*you might need to change the 'default full-text Language' for your database instance, I had to.