SQL Server 2012:为什么全文搜索不能索引.pdf,.cs?

时间:2015-07-23 15:46:24

标签: sql-server full-text-search

我已经安装了SQL Server 2012,然后执行了

select document_type 
from sys.fulltext_document_types

结果是50个扩展,好的。

然后我从Microsoft站点下载了FilerPack SP2,安装了它,执行了

EXEC sp_fulltext_service 'load_os_resources', 1
EXEC sp_fulltext_service 'update_languages' 

重新启动SQL Server并执行:

select document_type 
from sys.fulltext_document_types

结果是151个扩展名,包括.pdf,.cs等。

然后:

create table DocumentRepository
(
    id int not null primary key identity,
    fileName nvarchar(250),
    fileSize int,
    fileExtension NVARCHAR(10),
    attachment varbinary(max)
);
GO

GRANT INSERT,UPDATE,SELECT,DELETE on DocumentRepository to public;
GO

CREATE FULLTEXT CATALOG FTSCatalog AS DEFAULT;
GO

CREATE FULLTEXT INDEX ON dbo.DocumentRepository
(fileName, attachment TYPE COLUMN fileExtension)
KEY INDEX PK__Document__3213E83FEFB4F2B9
ON FTSCatalog
WITH CHANGE_TRACKING AUTO;
GO

并添加了一些文件:.pdf,.txt,.cs,.docx

  • Microsoft Project Silk.pdf 7963 .pdf
  • kdd-camera-ready-final.pdf 354 .pdf
  • pro_wcf_4_2nd_edition.pdf 22193 .pdf
  • dbw.txt 3 .txt
  • mydoc.docx 11 .docx
  • RollingFileAppender.cs 50 .cs

最后执行:

select * 
from DocumentRepository 
where contains(*, N'Firefox') 

------
0, (word inside pdf field)

select * 
from DocumentRepository 
where contains(*, N'Appender')

-----
0, (word inside .cs)

select * 
from DocumentRepository 
where contains(*, N'database')

--------
dbw.txt 3   .txt
mydoc.docx  11  .docx

为什么FTS不会搜索.pdf.cs个文件?

0 个答案:

没有答案