Index Server 1

由于网上的实例太多这就不对index server进行过多的描述,仅仅对代码中的极个别注意点进行说明,希望后来的和我一样走.net的人少些弯路.
string constr="PROVIDER=MSIDXS;DATA SOURCE=IndexData";         //调用msidxs索引服务,并指定起编录(IndexData)
            OleDbConnection con=new OleDbConnection(constr);
            
try
            
{                                                             //通过Scope来指定查找范围
                strOle="SELECT  Rank,FileName, Create, Access,  Path FROM SCOPE('"+strWhichMethod+" \""+strDataPath+"\"') where contains('xml')";  
                OleDbCommand cmd
=new OleDbCommand(strOle,con);
                con.Open();
                OleDbDataReader OleDaRead
=cmd.ExecuteReader(CommandBehavior.CloseConnection);
                
while(OleDaRead.Read())
                
{
                     arrFileName.Add( OleDaRead[
"FileName"].ToString());
                }

                cmd.Dispose();
            }

            
catch(Exception E)
            
{
                Debug.Write(E.Message);
            }

            
finally
            
{    
                con.Close();
            }
请注意 data souce 是指你在索引服务里自己创建的一个索引编录.这里的scope可以自己选择索引方法,比如在顶级目录下或在虚拟录下等,一共有四种在这里我都将其写为变量;各位自己调用scope提供的方法.已上就是我对index server的一点补充.
posted @ 2009-03-02 09:15  waynecn  阅读(248)  评论(0编辑  收藏  举报