昨天一个同事要了解Windows全文搜索的情况,无奈以前没用用过,所以昨天花了点时间对Indexing Service做了下简单的了解和编程尝试。

1.要使用Windows的全文搜索服务,首先要确保在“添加删除程序\添加删除Windows组件\”中安装了“索引服务”:

然后就可以使用Indexing Service了,包括进行编程。
安装了索引服务后就可以到“计算机管理\服务和应用程序\”中找到索引服务,并对之进行设置和管理:

默认情况下会有两个编目(Catalog),System和Web,分别用于建立和维护本地文件和本地网站的索引。每个编目包含了多个目录(Scope),并有一个属性(Property)集合。
 
2.关于Windows Indexing Service的相关文档、编程参考和代码片断都可以在msdn中找到,下面是链接:
 
3.由于IndexingService相关API都是通过COM组件的形式提供的,因此如果要在程序中调用相关API,就必须首先添加对如下Type Library的引用:
API Reference Library
Admin Helper Indexing Service Administration Type Library 1.0 CIODMLib
Query Helper ixsso Control Library Cisso
ADO Micorsoft ActiveX Data Objects (ADO) version Library, where version is one of the available versions. ADODB
下面是对Indexing Service进行设置和管理的编程对象:
Object name Description
AdminIndexServer Manages Indexing Service. Allows access to all the functionality provided by the Microsoft Management Console (MMC) snap-in.
CatAdm Manages the collection of scopes for a catalog.
ScopeAdm Manages an individual scope.
下面是通过IndexingService进行全文搜索的编程对象:
Object name Description
Query Manages the query definition and result-set creation and navigation.
Utility Helpful utilities for managing the queries and result sets.
msdn的文档中提供了一些比较简单的示例代码,分别由VBScript, JScript, Visual Basic, Visual C++, 和Visual J++的代码,好像没有.NET的代码。
 
4.如果是.NET环境下要使用Indexing Service同样是需要引用上面三个COM组件:

然后就可以在代码中通过Interop包装后的类来调用API了。下面是一段实现了简单搜索功能的示例代码:
上面只是简单的了解了一下Indexing Service,并且尝试编写了一个很简单的示例而已,欢迎大家交流并希望高手指教:)
 
posted on 2005-02-22 10:08  Laser.NET  阅读(13352)  评论(15编辑  收藏  举报
无觅相关文章插件,快速提升流量