SQL Server 全文搜索没有结果

发布于 2024-08-31 17:20:40 字数 2112 浏览 3 评论 0原文

我有带有高级服务的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昵称有卵用 2024-09-07 17:20:40

好吧,这一切都归结为搜索文本的格式。

这是错误的:

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

这是正确的:

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

一切正常!

Well it all boiled down to the formatting of the search text.

This was incorrect:

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

This was correct:

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

Everything is working fine!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文