整合下查询到的相关资料,给自己备忘,大家有需要可以参考
SELECT FULLTEXTSERVICEPROPERTY('IsFullTextInstalled');--查看是否安装FullText
CREATE FULLTEXT CATALOG name_catalog;--创建catalog
CREATE FULLTEXT INDEX ON name_table
(
title --Full-text index column name
Language 1033 --1033 is the LCID for English
)
KEY INDEX PK_fulltextindexname ON name_catalog--Unique index,PK_fulltextindexname是我们预先在目标表格name_table中创建的全文索引名
WITH CHANGE_TRACKING AUTO --Population type;
GO
select * from sys.fulltext_languages;--查看不同语言对应的Language LCID
--基本查询,会自动过滤干扰词
select * from name_table where contains(title, '"key words"');
select * from name_table where freetext(title, '"key words"');
exec sp_help_fulltext_tables
EXEC sp_fulltext_database 'enable'
EXEC sp_help_fulltext_tables-- 查找全文索引表名
DROP FULLTEXT INDEX ON dbo.name_table-- 删除索引INDEX(if TableName:dbo.name_table)
EXEC sp_help_fulltext_catalogs-- 查询全文索引目录
DROP FULLTEXT CATALOG name_catalog-- 删除索引目录
EXEC dbo.sp_helpindex name_table
--查看表中所有关键词
SELECT * FROM sys.dm_fts_index_keywords_by_document(db_id('name_db'), object_id('dbo.name_table'))
--查看被分解成了那些关键词
SELECT * FROM sys.dm_fts_parser (
'"key words"', --待分解的语句
1033, --语言编号, 1033代表English,语言编号信息可以通过查看sys.fulltext_languages表获取
0, -- stoplist: 0表示使用默认的,NULL表示不使用。
0 -- accent_sensitivity,0表示insensitivity,1表示sensitivity
);
--按相关度排序
select top 100 * from name_table t
join freetexttable(name_table ,(title),'"key words"') k on t.fileName=k.[key] order by k.[rank] desc