打印本文 打印本文 关闭窗口 关闭窗口
Exchange全文检索概述
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2032  更新时间:2009/4/22 23:22:07  文章录入:mintao  责任编辑:mintao
;oStream = oRequest.GetRequestStream();
    oStream.Write(abData,0,abData.Length);
    oStream.Close();
    // waiting for response
    try
    {
     oResponse = (System.Net.HttpWebResponse) oRequest.GetResponse();
     oRequest = null;
    }
    catch(System.Exception e)
    {
     Trace.WriteLine("SendSearchRequest: " + e.Message);
    }
    if (oResponse != null)
    {
     oStream = oResponse.GetResponseStream();
     // get data from stream
     if (oStream != null)
     {
      try
      {
       xmldoc = new XmlDocument();
       if (xmldoc != null)
       {
        xmldoc.Load(oStream);
       }
      }
      catch(System.Exception e)
      {
       Trace.WriteLine("SendSearchRequest: " + e.Message);
      }
      oStream.Close();
      oStream = null;
     }
    }
    oResponse = null;
   }      return xmldoc;
  }
    传入参数分别为,需要查询的根路径(可以认为是表名,这里为HTTP URL)和查询语句(格式见上一节),返回的结果为包含查询结果的XMLDocument实例。       3-3-2、ADO。     Exchange提供了两种Provider,ExOLEDB和MSDAIPP,可供ADO调用,但是只有MSDAIPP这个Provider支持全文检索,而且当在Exchange安装的主机上采用MSDAIPP进行全文检索时,会产生一些不可知的错误,比如挂起之类,所以建议采用WebDAV。     ADO的示例如下:   private ADODB.RecordsetClass GetQueryResult(System.String sUrl,System.String sQuery)
  {
   ADODB.RecordsetClass rsResult = null;
   ADODB.ConnectionClass cnnExchange = null;
   ADODB.CommandClass  cmdQuery = null;
   System.Object   objAffectedRecords = null,objParams = null;
     if (sUrl == null || sUrl == String.Empty)
    return null;
   if (sQuery == null || sQuery == String.Empty)
    return null;
     try
   {
    cnnExchange = new ConnectionClass();
    if (cnnExchange == null)
     return null;
    cnnExchange.Provider = "provider=msdaipp.dso";
    cnnExchange.Open(sUrl,String.Empty,String.Empty,0);
   }
   catch (System.Exception e)
   {
    Trace.WriteLine("GetQueryResult: Create connection failed! " + e.Message);
    cnnExchange = null;
    return null;
   }
     cmdQuery = new CommandClass();
   if (cmdQuery != null)
   {
    cmdQuery.ActiveConnection = cnnExchange;
    cmdQuery.CommandType = CommandTypeEnum.adCmdText;
    cmdQuery.CommandText = sQuery;
    try
    {
     rsResult = (ADODB.RecordsetClass) cmdQuery.Execute(out objAffectedRecords,ref objParams,0);
    }
    catch (System.Exception e)
    {
     Trace.WriteLine("GetQueryResult: Query data failed! " + e.Message);
    }
    cmdQuery = null;
   }
   cnnExchange = null;
     return rsResult;
  }
    传入参数分别为,需要查询的根路径(可以认为是表名)和查询语句,返回的结果为包含查询结果的Recordset实例。需要强调的是MSADIPP的Provider不支持在打开连接时指定访问用户名和口令。
      以上就是在Exchange下全文检索的简要介绍。有关IFilter和存储引擎开发的要点,等有机会再进一步阐述。     参考文档 A、SQL Server体系结构(Full-Text Support)(http://msdn.microsoft.com/library/en-us/architec/8_ar_sa2_0ehx.asp) B、Using Custom Filter With Index Service(http://msdn.microsoft.com/library/en-us/indexsrv/html/ixufilt_912d.asp) C、Exchagne Store SQL(http://msdn.microsoft.com/library/en-us/wss/wss/_exch2k_sql_web_storage_system_sql.asp)  

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口