SQL Server 全文搜索没有结果
我有带有高级服务的 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
我意识到填充全文索引可能需要一些时间。然而,尽管花了很长时间(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
表FullTextChangeTrackingOn 1
表全文文档已处理 11024
表全文失败计数 0
表全文项目计数 4038
表全文关键字列 1
表全文PendingChanges 0
TableHasActiveFulltextIndex 1
然后,我尝试对索引进行全新的完整填充,如下所示:
alter fulltext index on Cell start full population
我收到以下警告:
警告:在表或索引视图“单元格”上启动全文索引填充的请求被忽略,因为该表或索引视图的填充当前处于活动状态。
我尝试按如下方式更新填充:
alter fulltext index on Cell start update population
返回:“命令成功完成。”,但是我在全文搜索中仍然没有得到任何结果。
我缺少什么?我需要做什么才能让全文搜索正常工作?
谢谢,埃兰
I have SQL Server 2005 Express Edition with Advanced Services. I enabled FullText and created a catalog as follows:
create FullText catalog MyDatabase_FT in path 'mypath' as default
I then created a FullText index as follows:
create FullText index on Cell (CellName) key index PK_Cell
with CHANGE_TRACKING AUTO
I executed the following queries:
1) select count(*) from Cell where contains (CellName, 'CU*')
2) select count(*) from Cell where CellName like 'CU%'
And got the following results:
1) 0
2) 24
I realize that it could take some time to populate the FullText indexes. However, despite much time (12 hours) I still get no results. I then investigated further using the ObjectPropertyEx() function and executed the following:
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')
This gave the following results:
TableFullTextBackgroundUpdateIndexOn 1
TableFullTextChangeTrackingOn 1
TableFulltextDocsProcessed 11024
TableFulltextFailCount 0
TableFulltextItemCount 4038
TableFulltextKeyColumn 1
TableFulltextPendingChanges 0
TableHasActiveFulltextIndex 1
I then tried to do a fresh full population of the index as follows:
alter fulltext index on Cell start full population
And I get the following warning:
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.
I tried an update population as follows:
alter fulltext index on Cell start update population
This returned: "Command(s) completed successfully.", however I still get no results on the FullText search.
What am I missing? What do I need to do to get the FullText search working?
Thanks, Elan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,这一切都归结为搜索文本的格式。
这是错误的:
这是正确的:
一切正常!
Well it all boiled down to the formatting of the search text.
This was incorrect:
This was correct:
Everything is working fine!