indexing service相关资源(转)

1.Microsoft Indexing Service 相关资料
http://blog.csdn.net/zhumkcn/archive/2004/11/08/172171.aspx

2.使用范例1
http://www.21cnvip.com/csdn/html/20010829/09/260989.html

配置index   server
  在执行web服务器上的搜索之前,首先必须创建至少一个索引,并遵循以下步骤完成这项工作。    
   
  ⒈启动windows   2000   server服务器上的索引。    
   
  缺省情况下选择图标位于管理工具组中的计算机管理。窗口的右边提供关于当前在服务器上  
  存在的索引信息。默认有两个索引:system和web。    
   
  ⒉要创建新的索引,用鼠标右键单击索引服务或右边的面板,选定新建编录。    
   
  显示添加编录对话框,指定索引的名称并用浏览按钮选取位置。索引服务不会立即开始索引,此时将弹出一条消息框,单  
  击确定继续。为了达到最佳的性能,索引服务可以放在和web服务器隔离开的硬盘上。    
   
  ⒊指定索引的目录,用右键单击新建的编录名,从弹出选单中选定属性,将出现如图2所示的对话框。    
   
  第一个选项卡常规显示刚刚输入的内容,在第二个选项卡跟踪中的www服务器下拉列表中选取你要索引的web网站。    
   
  ⒋有了创建的编录,现在可以挑选你想在索引中包括的目录。    
   
  这个强大的特性使你能创建几个用不同方式搜索内容的索引。例如,你可能想快速浏览从完整的文本中所引出的章节,这  
  个特性使你能在index   server内执行这项任务。要添加一个目录,用右键单击右边的面板,选定新建目录。在出现的对话  
  框中通过浏览按钮选择目录并指定别名。如果必须登录到服务器才能得到需要的内容,则可以提供将使用的用户名和密  
  码,以便得到需要的内容。如果想检查受保护的内容,则更要维护内容的安全性,这一特性非常有用,这样只有被授权的  
  用户(也许是那些为此付钱的人)才能得到完整的内容。    
   
  还可以使用这个工具排除web站点中不想索引的子目录。例如,检索scripts/cgi目录就不会对用户有什么用。为此,只要  
  双击该目录,将包括在索引中选定为否即可,见图3。    
   
  ⒌在已经为站点包括/排除了所有目录后,用右键单击右面板,从弹出选单中选定启动,重新启动index   server服务。    
   
  服务器将开始浏览已经创建的索引并开始检索内容。    
   
  源程序:    

1、search.asp   
  
< html >    
  
< head >    
  
< title > the   indexing   service </ title >    
  
< style    type ="text/css" >    
  body   
{font-family:tahoma,arial,sans-serif;   font-size:10pt}   
  .heading   
{font-family:tahoma,arial,sans-serif;   font-size:14pt;   font-weight:bold}   
  .cite   
{font-family:tahoma,arial,sans-serif;   font-size:8pt}   
  
</ style >    
  
</ head >    
  
< body    bgcolor ="#ffffff" >    
  
< span    class ="heading" > searching   the   indexing   service   using   ado </ span >< hr >    
  
<!-- ----------------------------------------------------------------------- -->    
    
  
< form    name ="frmsearch"    action ="queryindexserver.asp"    method ="post" >    
  search   for:   
< input    type ="text"    name ="txtsearchfor" >    
  
< p >    
  
< input    type ="submit"    value ="perform   search" >    
  
< input    type ="reset"    value ="clear   form" >    
  
</ form >    
    
  
</ body >    
  
</ html >    
  2、queryindexserver.asp   
  
< title > the   indexing   service </ title >    
  
< style    type ="text/css" >    
  body       
{font-family:tahoma,arial,sans-serif;   font-size:10pt}   
  .heading   
{font-family:tahoma,arial,sans-serif;   font-size:14pt;   font-weight:bold}   
  .cite     
{font-family:tahoma,arial,sans-serif;   font-size:8pt}   
  .document   
{font-size:10pt;   font-weight:bold;   background-color:lightgrey;   width:100%}   
  
</ style >    
  
</ head >    
  
< body    bgcolor ="#ffffff" >    
  
< span    class ="heading" > results   of   search   for   
  
< i > <% = request.form( " txtsearchfor " ) %> </ i >    
  
</ span >< hr >    
  
<!-- ----------------------------------------------------------------------- -->    
    
  
<%    
    
      
dim   strsearch   
    
      
set   rssearch   =   server.createobject("adodb.recordset")   
    
      
'   create   the   connection   string   
      strconn   =   "provider=msidxs;   data   source=web"   
    
      
'   construct   the   search   string   
      strsearch   =   "select   doctitle,   path,   filename,   characterization,   size,write"   &   _   
                              
"   from   scope()"   &   _   
                              
"   where   contains   ('"   &   request.form("txtsearchfor")   &   "')"   
    
      
'   open   the   recordset   on   the   search   
      rssearch.open   strsearch,strconn   
    
      
'   show   what's   been   searched   for   
      while   not   rssearch.eof   
          response.write   
"<span   class='document'>"   &   rssearch("doctitle")   &   "</span><br>"   &   _   
                                        rssearch(
"characterization")   &   "<br>"   &   _   
                                        
"<a   href='"   &   rssearch("path")   &   "'>"   &   rssearch("write")   &   "</a>"   &   _   
                                        
"   ("   &   rssearch("size")   &   "   bytes)<p>"   
          rssearch.movenext   
      
wend   
    
      
'   tidy   up   
      rssearch.close   
      
set   rssearch   =   nothing   
  
%>    
    
    
  
</ body >    
  
</ html >    


  采用默认的web索引!  

3.VC  COM使用范例

http://sourceoflife.bokee.com/1770263.html

其实实现Indexing Service,主要涉及的就是COM组件在VC中的使用
这里Indexing Service Manage函数在ciodm.dll中,并且查询使用的是数据库查询的模式,
所以需要
#import 
" C:Program FilesCommon FilesSystemadomsado15.dll "  no_namespace 

rename(
" EOF " , " adoEOF "
#import 
" ciodm.dll "  no_namespace named_guids
if (S_OK != OleInitialize(NULL))
{
 AfxMessageBox(
"初始化COM组件库错误");
}


/初始化方法一/////

IAdminIndexServerPtr pIIndexAdmin;  
// 服务
 ICatAdmPtr    pICatAdmin;    // 编录
 IScopeAdmPtr   pIScopeAdmin;   // 目录
 HRESULT hr  =  S_OK;
 DWORD dwError 
=   0 ;
 CString strErrorMsg;

 
// *****************************************************
 
//  创建索引服务实例
 
// *****************************************************
  try
 
{
  
//创建索引服务实例
  hr = pIIndexAdmin.CreateInstance(__uuidof(AdminIndexServer));
  
if!SUCCEEDED(hr) )
  
{
   MessageBox(
"创建索引服务对象失败,请检查是否安装索引服务");
   
return ;
  }

 }

 
catch (...)
 
{
  strErrorMsg.Format(
"创建索引服务对象异常,请检查是否安装索引服务异常错误号为%d",GetLastError());
  MessageBox(strErrorMsg);
  
return ;
 }

 
 
// *******************************************************
 
// 获取编录对象,如果不存在,则添加
 
// *******************************************************
  try
 
{
  pICatAdmin 
= pIIndexAdmin->GetCatalogByName("ThirdIndex");
  
  
//存在编录,那么看服务是否启动,如果没有启动,启动服务
  if!pIIndexAdmin->IsRunning() ) 
  
{
   pIIndexAdmin
->Start();
  }

  
//启动编录
  if!pICatAdmin->IsCatalogRunning() ) 
  
{
   pICatAdmin
->StartCatalog();
  }


 }

 
catch  (_com_error e)
 
{
  dwError 
= LOWORD( e.Error() );
  
if( dwError == ERROR_NOT_FOUND )
  
{
   
//如果不存在编录,那么创建编录
   CreateDirectory("E:/ThirdIndex",NULL);
   CreateDirectory(
"E:/ThirdMulu",NULL);
   
//如果服务已经启动,那么先停止服务,创建编录,然后启动服务
   if( pIIndexAdmin->IsRunning() ) 
   
{
    pIIndexAdmin
->Stop();
   }


   
//创建编录
   pICatAdmin = pIIndexAdmin->AddCatalog("ThirdIndex","E:/ThirdIndex");
   
   
//启动编录
   if!pIIndexAdmin->IsRunning() ) 
   
{
    pIIndexAdmin
->Start();
   }

   
//启动编录
   if!pICatAdmin->IsCatalogRunning() ) 
   
{
    pICatAdmin
->StartCatalog();
   }

  }

  
else
  
{
   strErrorMsg.Format(
"COM错误:获取编录对象异常,错误号为%d",dwError);
   MessageBox(strErrorMsg);
  }

 }

 
catch (...)
 
{
  strErrorMsg.Format(
"获取编录对象异常,错误号为%d",GetLastError());
  MessageBox(strErrorMsg);
  
return ;
 }

 
 
 
// *******************************************************
 
// 如果目录不存在,那么创建目录
 
// *******************************************************
  try
 
{
  pIScopeAdmin 
= pICatAdmin->GetScopeByPath("E:/ThirdMulu");
 }

 
catch  (_com_error e)
 
{
  dwError 
= LOWORD( e.Error() );
  
if( dwError == ERROR_NOT_FOUND )
  
{
   pIScopeAdmin 
= pICatAdmin->AddScope("E:/ThirdMulu",FALSE);
  }

  
else
  
{
   strErrorMsg.Format(
"COM错误:获取目录对象异常,错误号为%d",dwError);
   MessageBox(strErrorMsg);
  }

 }

 
catch (...)
 
{
  strErrorMsg.Format(
"获取目录对象异常,错误号为%d",GetLastError());
  MessageBox(strErrorMsg);
  
return ;
 }


 MessageBox(
" 初始化完毕 " );
 

/初始化创建服务实例方法二//

IUnknown 
* pIUnknown = NULL;
 IAdminIndexServer 
* pIAdminIS = NULL;
 HRESULT hr
= CoCreateInstance(CLSID_ADMINIS ,NULL ,CLSCTX_INPROC_SERVER,IID_IUnknown , (LPVOID * ) & pIUnknown);
 
if  (  ! SUCCEEDED(hr) )
 
{
  MessageBox(
"Error");
  
return ;
 }

 
// 接口的
 hr = pIUnknown -> QueryInterface(IID_IAdminIndexServer ,( void ** ) & pIAdminIS);

 
if ( ! SUCCEEDED(hr) )
 
{
  MessageBox(
"Error1");
  
return ;
 }


 pIUnknown
-> Release();
 pIAdminIS
-> AddCatalog( " ThirdIndex " , " E:/ThirdIndex " );
 pIAdminIS
-> Release();

/添加编录方法二/////

// *******************************************************
 
// 添加编录,如果存在会提示已经存在
 
// *******************************************************
  try
 
{
  CreateDirectory(
"E:/ThirdIndex",NULL);
  CreateDirectory(
"E:/ThirdMulu",NULL);
  pICatAdmin 
= pIIndexAdmin->AddCatalog("ThirdIndex","E:/ThirdIndex");
 }

 
catch  (_com_error e)
 
{
  dwError 
= LOWORD( e.Error() );
  
if( dwError == ERROR_ALREADY_EXISTS )
  
{
   MessageBox(
"编录已经存在");
   pICatAdmin 
= pIIndexAdmin ->GetCatalogByName("ThirdIndex");
  }

  
else
  
{
   strErrorMsg.Format(
"COM错误:获取编录对象异常,错误号为%d",dwError);
   MessageBox(strErrorMsg);
  }

 }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值