文档详情

ISQLserver2008全文检索使用方法.doc

发布:2017-01-11约2.87千字共8页下载文档
文本预览下载声明
SQLserver2008全文检索使用方法 开启SQL Full-text服务 图1 开启 SQLServer Full-text服务 保证 SQL Full-text Filter Daemon Launcher服务处于开启状态,不同版本SQLServer全文检索服务名称可能稍有不同,如果服务列表中没有这个服务,请使用SQLServer安装光盘安装“全文检索”组件。 启用全文检索 执行SQL语句启用全文检索: Execute sp_fulltext_database enable 设置全文语言为中文 图2 设置全文语言 在服务器-属性-高级中,设置默认全文语言为2052(中文)。 建立数据表 在需要全文检索的数据表中,必须有一列字符型的字段存放文件类型,例如建表语句中的FileType。必须有一列Varbinary(Max)类型的字段存放文件内容,例如建表语句中的FileContent。 建表SQL语句示例: CREATE TABLE SampleBlobTable ( [PKID] int identity(1,1) primary key, [FileName] Nvarchar(255) null, [FileType] Nvarchar(32) null, [FileContent] VARBINARY(MAX) NULL, [AddTime] datetime default(getdate()) ) 建立全文索引 步骤1 建立全文索引 在需要全文检索的数据表上点击右键-全文索引-定义全文索引。 步骤2 选择唯一索引 步骤3 选择表列 选择表列,本例中以FileType列标明文件格式,将文件存入数据库时须正确填写此字段,此字段中的数据内容包括“doc”、“txt”、“xls”等。 后续步骤无需更改默认值,点击下一步继续直至完成。 支持PDF文件 安装 Adobe iFilter Adobe iFilter6.0: /support/downloads/thankyou.jsp?ftpID=2611fileID=2457 Adobe iFilter9.0 for 64bit: /support/downloads/thankyou.jsp?ftpID=4025fileID=3941 执行SQL语句 exec sp_fulltext_service load_os_resources, 1; exec sp_fulltext_service verify_signature, 0; 重新启动 SQLSERVER 检查支持文件 执行下列语句: select document_type, path from sys.fulltext_document_types where document_type = .pdf,如查询结果为下图则表示成功,可以进行PDF的全文检索了。 l 图3 执行结果 查询语法及示例 语法 CONTAINS ( { column | * } , contains_search_condition ) contains_search_condition ::= { simple_term | prefix_term | generation_term | proximity_term | weighted_term } | { ( contains_search_condition ) { AND | AND NOT | OR } contains_search_condition [ ...n ] } simple_term ::= word | phrase prefix term ::= { word * | phrase * } generation_term ::= FORMSOF ( INFLECTIONAL , simple_term [ ,...n ] ) proximity_term ::= { simple_term | prefix_term } { { NEAR | ~ } { simple_term | prefix_term } } [ ...n ] weighted_term ::= ISABOUT ( { { simple_term | prefix_term | generation_term | proximity_term } [ WEIGHT ( weight_value ) ] } [ ,...n ] ) 示例 查找文件内容含“合同”的数据。 select * from SampleBlobTable where co
显示全部
相似文档