我有带高级服务的SQL Server 2005 Express Edition。我启用了FullText并创建了一个目录,如下所示:
create FullText catalog MyDatabase_FT in path 'mypath' as default
然后我创建了一个FullText索引,如下所示:
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
这返回:“命令已成功完成。”但是我仍然没有在FullText搜索中得到任何结果。
我错过了什么?我需要做什么才能使FullText搜索工作?
谢谢,Elan
答案 0 :(得分:4)
这一切都归结为搜索文本的格式化。
这是不正确的:
select count(*) from Cell where contains (CellName, 'CU*')
这是正确的:
select count(*) from Cell where contains (CellName, '"CU*"')
一切正常!