2

我有带高级服务的SQL Server 2005 Express Edition。我启用了全文,并创建一个目录,如下所示:SQL Server全文搜索不会产生结果

create FullText catalog MyDatabase_FT in path 'mypath' as default 

然后,我创建了一个全文索引如下:

create FullText index on Cell (CellName) key index PK_Cell 
    with CHANGE_TRACKING AUTO 

我执行以下查询:

1) select count(*) from Cell where contains (CellName, 'CU*') 
2) select count(*) from Cell where CellName like 'CU%' 

,并得到了以下结果:

1)0
2)24

我意识到可能需要一些时间来填充FullText索引。但是,尽管时间很长(12小时),但我仍然没有得到任何结果。然后我调查进一步使用OBJECTPROPERTYEX()函数和所执行的以下操作:

declare @id int 
select @id = id FROM sys.sysobjects where [Name] = 'Cell' 
select 'TableFullTextBackgroundUpdateIndexOn' as 'Property', objectpropertyex(@id, 'TableFullTextBackgroundUpdateIndexOn') as 'Value' 
union select 'TableFullTextChangeTrackingOn', objectpropertyex(@id, 'TableFullTextChangeTrackingOn') 
union select 'TableFulltextDocsProcessed', objectpropertyex(@id, 'TableFulltextDocsProcessed') 
union select 'TableFulltextFailCount', objectpropertyex(@id, 'TableFulltextFailCount') 
union select 'TableFulltextItemCount', objectpropertyex(@id, 'TableFulltextItemCount') 
union select 'TableFulltextKeyColumn', objectpropertyex(@id, 'TableFulltextKeyColumn') 
union select 'TableFulltextPendingChanges', objectpropertyex(@id, 'TableFulltextPendingChanges') 
union select 'TableHasActiveFulltextIndex', objectpropertyex(@id, 'TableHasActiveFulltextIndex') 

这得到以下结果:

TableFullTextBackgroundUpdateIndexOn 1
TableFullTextChangeTrackingOn 1
TableFulltextDocsProcessed 11024
TableFulltextFailCount 0
TableFulltextItemCount 4038
TableFulltextKeyColumn 1
个TableFulltextPendingChanges 0
TableHasActiveFulltextIndex 1

然后我试着做索引的新鲜全人群如下:

alter fulltext index on Cell start full population 

而且我得到以下警告:

Warning: Request to start a full-text index population on table or indexed view 'Cell' is ignored because a population is currently active for this table or indexed view.

我尝试更新人口如下:

alter fulltext index on Cell start update population 

返回:“Command(s)completed successfully。”,但我仍然没有在FullText搜索中得到任何结果。

我错过了什么?我需要做些什么才能使FullText搜索工作?

感谢,义隆

回答

4

那么这一切归结到搜索文本的格式。

这是不正确的:

select count(*) from Cell where contains (CellName, 'CU*') 

这是正确的:

select count(*) from Cell where contains (CellName, '"CU*"') 

一切正常!