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*"') 

一切正常!