SQL 2008:关闭全文搜索查询的停用词 [英] SQL 2008: Turn off Stop Words for Full Text Search Query
问题描述
假设我有一个Company表,其中有一列名为名称。我有这个专栏的全文目录。如果用户搜索非常好的公司,我的查询将是:
SELECT
*
FROM
公司
其中
CONTAINS(名称,'非常和良好AND公司')
问题是在这个例子中,Very一词出现在停用词的标准列表中:
SELECT
ssw。*
FROM
sys.fulltext_system_stopwords ssw
WHERE
ssw.language_id = 1033;
导致查询返回时没有行,即使有一行名为Very Good公司。
我的问题是,如何关闭查询的停用词?或者我会怎样去完全去除它们?
或者我还有另外一种方法去处理这个搜索?
如果有其他人绊倒这个问题:
看起来2008年有这样的选择。这对我来说并不明显,因为数据库从2005年开始升级,我不认为这是一个选项。
您需要做的第一件事是设置直到2008年的兼容级别:
ALTER DATABASE [MyDatabase] SET COMPATIBILITY_LEVEL = 100
然后,通过向导创建全文索引时,您可以忽略索引的停用词
编辑:下面是脚本:/ b>
ALTER FULLTEXT INDEX ON MyTable SET STOPLIST = OFF
I'm having quite a bit of difficulty finding a good solution for this:
Let's say I have a table of "Company", with a column called "Name". I have a full-text catalog on this column. If a user searched for "Very Good Company", my query would be:
SELECT
*
FROM
Company
WHERE
CONTAINS(Name, '"Very" AND "Good" AND "Company"')
The problem is in this example, the word "Very" shows up in the standard list of stopwords:
SELECT
ssw.*
FROM
sys.fulltext_system_stopwords ssw
WHERE
ssw.language_id = 1033;
Resulting in the query returning with no rows, even though there is a row with the name "Very Good Company".
My question is, how would I go about turning the stopwords off for my query? Or how would I go about removing them entirely?
Or is there another way I should be going about this search?
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
这篇关于SQL 2008:关闭全文搜索查询的停用词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!