【发布时间】:2018-07-17 21:45:30
【问题描述】:
我有一个 MS SQL 数据库,其中包含一个包含各种文档(Word、Excel、PDF 等)的二进制图像的表。 我为全文搜索安装了 Office 过滤器。
我跑了:
EXEC sp_fulltext_service 'load_os_resources', 1
exec sp_fulltext_service 'update_languages';
EXEC sp_fulltext_service 'restart_all_fdhosts'
有问题的表有一个 content(Varbinary(MAX)) 字段,其中包含文件的实际二进制内容和一个 mime 类型字段。 我添加了一个新列,用于评估 mime 类型并设置适当的文档扩展名:
alter table core.DocumentObjectContent
add Extension as (case when contenttype = 'application/msword' then '.doc'
when contenttype = 'application/vnd.openxmlformats-officedocument.presentationml.presentation' then '.pptx'
when contenttype = 'application/pdf' then '.pdf'
when contenttype = 'application/vnd.ms-excel' then '.xls'
when contenttype = 'application/vnd.ms-powerpoint' then '.ppt'
when contenttype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' then '.xlsx'
when contenttype = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' then '.docx' end)
我创建了全文搜索目录:
CREATE FULLTEXT CATALOG ftCatalogY AS DEFAULT;
CREATE FULLTEXT INDEX ON core.DocumentObjectContent(content Type column extension) KEY INDEX PK_DocumentObjectContent ON ftCatalogY;
它建立了它的索引,但索引似乎是空的:
这个查询:
SELECT * FROM sys.dm_fts_index_population
将 FTS 索引显示为“开始”。对 sys.fulltextcatalogs 表的查询返回“空闲”状态。
一个简单的选择:
select *
from core.DocumentObjectContent
where contains(content, 'a')
不返回任何结果。
有人知道我做错了什么吗?让我发疯:)
【问题讨论】:
-
可能是个愚蠢的问题,但您是否真的将文档导入
DocumentObjectContent表?SELECT count(1) from core.DocumentObjectContent会为您返回什么?
标签: sql-server indexing full-text-search