我有一个单词表,想要添加到 SQL Server 中的停用词。我该怎么办?
我应该一一添加吗?
我尝试:
insert into sys.fulltext_stopwords (stopword) select stopword from Table_1
但出现此错误:
消息 259,第 16 级,状态 1,第 1 行
不允许对系统目录进行临时更新。
我使用 SQL Server 2022。
创建非索引字表:
CREATE FULLTEXT STOPLIST CustomStoplist;
将停用词添加到停用词列表中:
DECLARE @stopword NVARCHAR(64);
DECLARE stopword_cursor CURSOR FOR
SELECT stopword FROM Table_1;
OPEN stopword_cursor;
FETCH NEXT FROM stopword_cursor INTO @stopword;
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC sys.sp_addstopword @stopword = @stopword, @stoplist_name = 'CustomStoplist';
FETCH NEXT FROM stopword_cursor INTO @stopword;
END
CLOSE stopword_cursor;
DEALLOCATE stopword_cursor;
将非索引字表与全文索引相关联:
CREATE FULLTEXT INDEX ON YourTableName
(
YourColumnName
)
KEY INDEX YourPrimaryKeyIndex
WITH STOPLIST = CustomStoplist;