为什么SQL全文索引不能返回包含#的单词的结果? [英] Why doesn't SQL Full Text Indexing return results for words containing #?

查看:146
本文介绍了为什么SQL全文索引不能返回包含#的单词的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我的查询就像下面的SQL Server 2005一样:

  SELECT * FROM表WHERE FREETEXT(SearchField, 'c#')

我有一个全文索引定义为使用SearchField列,它在使用时返回结果:

  SELECT * FROM表WHERE SearchField LIKE'%c#%'

我相信#是一个特殊字母,那么如何让FREETEXT正确地用于上面的查询?

#char被标记为标点符号,因此被忽略,所以看起来我们将从字词索引忽略列表中删除字母C.



在完成之后在本地进行测试并重建索引并获得结果!



考虑在索引列上使用不同的断词语言,所以这些特殊字符不会被忽略。编辑:我还发现这个信息


c#被索引为c(如果c不在您的噪声字列表中,稍后会在噪声字列表中查看更多信息),但C#被索引为C#无论C或c在您的噪音词列表中,无论在Win2003上运行SQL 2000)。不仅C#存储为C#,而且任何大写字母后跟#。相反,c ++(和任何其他小写字母后跟一个++)的索引为c(无论c是否在您的噪音词列表中)。



For instance, my query is like the following using SQL Server 2005:

SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#') 

I have a full text index defined to use the column SearchField which returns results when using:

SELECT * FROM Table WHERE SearchField LIKE '%c#%'

I believe # is a special letter, so how do I allow FREETEXT to work correctly for the query above?

解决方案

The # char is indexed as punctuation and therefore ignored, so it looks like we'll remove the letter C from our word indexing ignore lists.

Tested it locally after doing that and rebuilding the indexes and I get results!

Looking at using a different word breaker language on the indexed column, so that those special characters aren't ignored.

EDIT: I also found this information:

c# is indexed as c (if c is not in your noise word list, see more on noise word lists later), but C# is indexed as C# (in SQL 2005 and SQL 2000 running on Win2003 regardless if C or c is in your noise word list). It is not only C# that is stored as C#, but any capital letter followed by #. Conversely, c++ ( and any other lower-cased letter followed by a ++) is indexed as c (regardless of whether c is in your noise word list).

这篇关于为什么SQL全文索引不能返回包含#的单词的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆