SQL Server上的pdf文件的全文搜索不会返回结果

时间:2014-09-13 22:03:28

标签: sql-server full-text-search adobe sql-server-2014

我已安装Adobe IFilter,通过运行以下查询来更改路径并创建全文索引

CREATE TABLE ResearchReport
(
   ResearchReportID int identity(1,1),
   Report varbinary(max),
   Title nvarchar(100) not null,
   Summary nvarchar(300) not null,
   Author nvarchar(150) not null,
   Country nvarchar(50) not null,
   Sector nvarchar(50) not null,
   Company nvarchar(50),
   Extension nvarchar(10) NOT NULL,
   CreationDate smalldatetime default getdate(),

   primary key(ResearchReportID)
);

EXEC sp_fulltext_database 'enable'
GO

IF NOT EXISTS (SELECT TOP 1 1 FROM sys.fulltext_catalogs WHERE name = 'Report_Catalog')
BEGIN
    EXEC sp_fulltext_catalog 'Report_Catalog', 'create';
END

DECLARE @indexName nvarchar(255) = (SELECT Top 1 i.Name from sys.indexes i
                                    Join sys.tables t on  i.object_id = t.object_id
                                    WHERE t.Name = 'ResearchReport' AND i.type_desc = 'CLUSTERED')

PRINT @indexName

EXEC sp_fulltext_table 'ResearchReport', 'create', 'Report_Catalog',  @indexName
EXEC sp_fulltext_column 'ResearchReport', 'Report', 'add', 0, 'Extension'
EXEC sp_fulltext_table 'ResearchReport', 'activate'
EXEC sp_fulltext_catalog 'Report_Catalog', 'start_full'

ALTER FULLTEXT INDEX ON [dbo].ResearchReport ENABLE
ALTER FULLTEXT INDEX ON [dbo].ResearchReport SET CHANGE_TRACKING = AUTO

EXEC sp_fulltext_service @action='load_os_resources', @value=1; -- update os resources 
EXEC sp_fulltext_service 'verify_signature', 0 -- don't verify signatures 
EXEC sp_fulltext_service 'update_languages'; -- update language list 
EXEC sp_fulltext_service 'restart_all_fdhosts'; -- restart daemon 
EXEC sp_help_fulltext_system_components 'filter'; -- view active filters
reconfigure with override

select * from ResearchReport查询返回结果但是当我想使用下面的查询之一进行全文搜索时,我没有得到任何结果,可能是什么问题?我已经检查了stackoverflow和google上的大部分问题,但无法找到答案。

SELECT r.* 
FROM dbo.ResearchReport r
WHERE Contains(r.Report, 'a')

SELECT * 
FROM ResearchReport 
WHERE freetext(Report, 'a')

2 个答案:

答案 0 :(得分:0)

SQL Server可以从全文索引中排除某些常见单词,以防止它们变得臃肿。

您可以尝试搜索更复杂的单词,或者关闭此索引的停止列表以检查是否存在问题。

ALTER FULLTEXT INDEX ON [dbo].ResearchReport SET STOPLIST = OFF

如果这是问题所在,并且您希望能够搜索“a”之类的字词,那么MSDN会有一个关于管理应该很方便的停用词的部分。 http://msdn.microsoft.com/en-us/library/ms142551.aspx

答案 1 :(得分:0)

原来Ifilter版本11没有真正测试过。当我删除11并安装9,然后重新创建索引它完美地工作。