服务器: 消息 7619,级别 16,状态 1,过程 pro_mai,行 17
查询子句只包含被忽略的词。
在 sql的全文索引中经常会出现这样的错误。
可以这样解决(一)
1. 所使用的搜索词就是忽略词,当然,我们使用的搜索词肯定也就是在目前系统看来正是忽略词无疑。但平时根本不是忽略词的词都成了忽略词就不正常了。
2. 忽略词包含在名为noise.*的文件中,他们放置在MSSQL的安装目录的“MSSQL\FTDATA\SQLServer\Config”目录下面,比如中文的忽略词放在noise.chs中。
3. 如果没有那么在C盘的system32目录下找到了一大段的名为noise的文件,将它们全部复制到MSSQL的安装目录的“MSSQL\FTDATA\SQLServer\Config”下面,期待的奇迹终于出现,中文可以正常使用全文索引了!最后附上一个zip文件,如果你没有此类noise文件,可以在此下载
http://www.asphouses.com/product/others/noise.zip
注意下载后,执行的时候是解压,要在解压后的目录中执行setup.bat才是真正的安装
b.配置全文索引时,单词断字符选择"中文(中国)"
c.Noise.chs文件中至少有一个单词,例如:?
d.如果在全文检索时,你能正常修改干扰词文件,说明你的全文检索没有使用上这个文件
如果你配置的全文检索应该要用到这个文件,那就在
企业管理器--展开你的数据库--右键全文目录--重建全部全文目录
4.表中的数据改变后,检索不到
方法1. 右键你的表--全文索引表--启用增量填充
方法2. 右键你的表--全文索引表--更改跟踪,这样以后的修改会自动填充(有一定延迟)
5.sql2000才支持对image列的全文检索
(二)
在javascript中解决
包括以下内容,然后调用:remove_noise_word()即可
<SCRIPT LANGUAGE=javascript>
<!--
noise_word_list_ch = new Array("?","about","$","1","2","3","4","5","6","7","8","9","0","_",
"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z","after","all","also",
"an","and","another","any","are","as","at","be","because","been",
"before","being","between","both","but","by","came","can","come",
"could","did","do","each","for","from","get","got","had","has",
"have","he","her","here","him","himself","his","how","if","in","into",
"is","it","like","make","many","me","might","more","most","much","must",
"my","never","now","of","on","only","or","other","our","out","over","said",
"same","see","should","since","some","still","such","take","than","that",
"the","their","them","then","there","these","they","this","those","through",
"to","too","under","up","very","was","way","we","well","were","what","where",
"which","while","who","with","would","you","your",
"的","一","不","在","人","有","是","为","以","于","上","他","而","后","之","来",
"及","了","因","下","可","到","由","这","与","也","此","但","并","个","其","已",
"无","小","我","们","起","最","再","今","去","好","只","又","或","很","亦","某",
"把","那","你","乃","它");
function trim_str_key(inputVal){
inputStr = inputVal.toString()
while ((inputStr.charAt(inputStr.length - 1) == " ") || (inputStr.charAt(0) == " ")){
//如果最右边为空格则删去
if (inputStr.charAt(inputStr.length - 1) == " "){
inputStr = inputStr.substring(0,inputStr.length - 1)
}
//如果最左边为空格则删去
if (inputStr.charAt(0) == " "){
inputStr = inputStr.substring(1,inputStr.length)
}
}
return inputStr
}
function is_ch_noise_word(str_key){
var key_word = trim_str_key(str_key);
key_word = key_word.toLowerCase();
var listlength=noise_word_list_ch.length;
var tmp_str = "";
for(i=0;i<listlength;i++){
tmp_str = noise_word_list_ch[i]
if(tmp_str==key_word){
return true;
}
}
return false;
}
function remove_noise_word(str_source){
var tmp_str = "";
var ch = "";
var str_out = "";
var i = 0;
str_source = trim_str_key(str_source);
var str_source_length = str_source.length;
if(str_source_length == 0){
return str_out;
}
for (i=0;i < str_source_length; i++){
ch = str_source.charAt(i);
if(ch==" "){ //如果为空格则表示是下一个关键词
if(!(is_ch_noise_word(tmp_str))){ //不是干扰词就输出
if(tmp_str!=" "){ //防止连续的两个空格
str_out = str_out + tmp_str + " ";
}
}
tmp_str = "";
}
else{
tmp_str = tmp_str + ch;
}
}
str_out = str_out + tmp_str;
return trim_str_key(str_out);
}
//下面是一个测试
//var abc = "av n";
//var nnnn = remove_noise_word(abc);
//alert(nnnn);
//-->
</SCRIPT>
-------------------------------------------------------
2005 中的 sql 干扰词
Microsoft SQL Server 2005 全文搜索包括改进和更新的干扰词文件。
这些干扰词文件位于以下目录中:
$SQL_Server_Install_Path\Microsoft SQL Server\MSSQL.1\MSSQL\FTDATA\
在同时设置 SQL Server 2005 和全文搜索支持时,会创建此目录并安装干扰词文件。
注意:如果您使用的是较低版本的 SQL Server 中的自定义干扰词文件,则在升级到 SQL Server 2005 后,这些自定义干扰词文件将不再有效。要继续使用这些自定义干扰词文件,必须按照“更多信息”一节中的步骤操作。
从 SQL Server 2000 或 SQL Server 7.0 升级到 SQL Server 2005 后,将根据改进和更新的 SQL Server 2005 干扰词文件填充全文目录。
来自以前 SQL Server 安装的干扰词文件将被放在以下目录中:
$SQL_Server_Install_Path\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\FTERef
此外,旧的干扰词文件名也将被更新。例如,简体中文干扰词文件名称将从 noise.chs 更新为 noiseCHS.MSSearch2x.txt。
要在升级到 SQL Server 2005 后继续使用旧的干扰词文件,请按照下列步骤操作: 1. 升级到 SQL Server 2005 后,立即停止全文目录填充。为此,对每个全文索引运行以下 ALTER FULLTEXT INDEX 命令:
ALTER FULLTEXT INDEX ON table_name STOP POPULATION
注意:在此命令中,table_name 是表名称的占位符。
如果启用了更改跟踪,请先运行以下命令禁用更改跟踪,然后再停止填充:
ALTER FULLTEXT INDEX ON table_name SET CHANGE_TRACKING OFF
有关如何停止全文索引填充的更多信息,请参见 SQL Server 联机丛书中的“更改全文索引 (Transact-SQL)”主题。
2. 将旧的干扰词文件从 $SQL_Server_Install_Path\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\FTERef 目录复制到 $SQL_Server_Install_Path\Microsoft SQL Server\MSSQL.1\MSSQL\FTDATA\ 目录。
注意:当升级群集解决方案时,旧的干扰词文件将被复制到以下安装节点目录中:
$SQL_Server_Install_Path\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\FTERef
3. 重命名旧的干扰词文件,以便与 SQL Server 2005 干扰词文件的名称一致。例如,将简体中文干扰词文件的名称 noiseCHS.MSSearch2x.txt 重命名为 noiseCHS.txt。
注意:必须先备份 SQL Server 2005 干扰词文件,然后再将其替换为旧的干扰词文件。
4. 重新填充全文目录。要重新启动填充,请对每个全文索引运行以下 ALTER FULLTEXT INDEX 命令:
ALTER FULLTEXT INDEX ON table_name START FULL POPULATION
如果要使用更改跟踪,请运行以下命令来重新启动填充并启用更改跟踪:
ALTER FULLTEXT INDEX ON table_name SET CHANGE_TRACKING {MANUAL|AUTO}
有关如何启动全文索引填充的更多信息,请参见 SQL Server 联机丛书中的“更改全文索引 (Transact-SQL)”主题。
以下代码是对步骤 1 中的每个全文索引停止全文索引填充的一个示例脚本。可以将此脚本改为对步骤 4 中的每个全文索引启动全文索引填充。
-- Sample script to stop full-text index population for
-- each full-text index.
DECLARE @table_name NVARCHAR(517),
@schema_name NVARCHAR(517);
DECLARE @exec_str NVARCHAR(4000);
DECLARE @change_tracking_state NCHAR(1);
-- Retrieve a list of tables with full-text indexes and stop
-- full-text index population for each full-text index.
DECLARE ms_crs_ftind CURSOR STATIC LOCAL FOR
SELECT t.name, SCHEMA_NAME(t.schema_id), ft.change_tracking_state
FROM sys.fulltext_indexes AS ft
JOIN sys.tables AS t
ON (ft.object_id = t.object_id);
OPEN ms_crs_ftind;
FETCH ms_crs_ftind INTO @table_name, @schema_name, @change_tracking_state;
WHILE @@FETCH_STATUS >= 0
BEGIN
-- If change tracking is enabled ('O' indicates change tracking
-- is OFF), stop change tracking before stopping population.
IF (@change_tracking_state != N'O')
BEGIN
SELECT @exec_str = 'ALTER FULLTEXT INDEX ON '
+ QUOTENAME(@schema_name,'[')+'.'+ QUOTENAME(@table_name,'[')
+ ' SET CHANGE_TRACKING OFF ';
EXEC (@exec_str);
END
-- Stop full-text index population for each full-text index.
SELECT @exec_str = 'ALTER FULLTEXT INDEX ON '
+ QUOTENAME(@schema_name,'[')+'.'+QUOTENAME(@table_name,'[')
+ ' STOP POPULATION ';
EXEC (@exec_str);
FETCH ms_crs_ftind INTO @table_name,@schema_name, @change_tracking_state;
END
DEALLOCATE ms_crs_ftind;