SQL 2008: Turn off Stop Words for Full Text Search Query

假装没事ソ 提交于 2019-11-28 06:49:21

In case anyone else stumbles upon this problem:

It looks like there is an option to do this in 2008; it wasn't apparent to me because the database was upgraded from 2005 where I don't believe this was an option.

The first thing you need to do is set the compatibility level up to 2008:

ALTER DATABASE [MyDatabase] SET COMPATIBILITY_LEVEL = 100

Then, when creating the full-text index through the wizard, there is a step that allows you to ignore stopwords for the index

edit: Here's the script to do it as well:

ALTER FULLTEXT INDEX ON MyTable SET STOPLIST = OFF

By default in SQL Server the stopwords are not ignored.

This is what you want to do:

sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'transform noise words', 1;
RECONFIGURE;
GO

REF: http://msdn.microsoft.com/en-us/library/ms187914%28v=sql.100%29.aspx

I was having this issue earlier today with the full text search.

151-663049 - returns result
151-66304 - no result
151-6630 - no result
151-663 - no result
151-66 - no result
151-6 - returns result
151 - returns result
151 returns result

But I read a post that says to get around the issue to append a * to the end of each search. http://social.msdn.microsoft.com/Forums/sqlserver/en-US/fae33a6b-7c7c-4c11-842c-ca5277ed824f/ms-sql-server-2008-r2-fulltext-search-problem

151-663049* - returns result
151-66304* - returns result
151-6630* - returns result
151-663* - returns result
151-66* - returns result
151-6* - returns result
151-* - returns result
151* - returns result

So in your parameter just append * to your searches and problem solved.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!