Windows Indexing Service的簡單嘗試

來源:互聯網
上載者:User
昨天一個同事要瞭解Windows全文檢索搜尋的情況,無奈以前沒用用過,所以昨天花了點時間對Indexing Service做了下簡單的瞭解和編程嘗試。

1.要使用Windows的全文檢索搜尋服務,首先要確保在“添加刪除程式\添加刪除Windows組件\”中安裝了“索引服務”:
然後就可以使用Indexing Service了,包括進行編程。

安裝了索引服務後就可以到“電腦管理\服務和應用程式\”中找到索引服務,並對之進行設定和管理:


預設情況下會有兩個編目(Catalog),System和Web,分別用於建立和維護本地檔案和以磁碟為基礎的網站的索引。每個編目包含了多個目錄(Scope),並有一個屬性(Property)集合。

 2.關於Windows Indexing Service的相關文檔、編程參考和代碼片斷都可以在msdn中找到,下面是連結:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/indexserv.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/indexsrv/html/ixrefobj_3skz.asp 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了。下面是一段實現了簡單搜尋功能的範例程式碼:
完整的範例程式碼下載:http://phoebusd.mofile.com/4484472520119593/7410790504088141/2/0B459B9BE5C0E179512B394A987B482E/FulltextSearchSample.rar 

程式的運行介面如下:


 上面只是簡單的瞭解了一下Indexing Service,並且嘗試編寫了一個很簡單的樣本而已,歡迎大家交流並希望高手指教:) 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.