Einzelnen Beitrag anzeigen

apolon

Registriert seit: 12. Apr 2003
7 Beiträge
 
#1

working with MS Index Server

  Alt 9. Jul 2004, 17:41
Dear All

I want to use Ms Index Server In my delphi App.
I found this code :
Delphi-Quellcode:
var
  Form1: TForm1;
  IndexQuery: TCissoQuery;
  IndexUtil: TCissoUtil;
implementation

{$R *.dfm} 

procedure TForm1.FormCreate(Sender: TObject);
var
   IndexServerAdmin: TAdminIndexServer;
   CatAdm : TCatAdm;

begin
  //Both IndexQuery and IndexUtil objects are declared in main unit
   IndexQuery := TCissoQuery.Create(nil);
   IndexUtil := TCissoUtil.Create(nil);
   //Let's display a list of catalogs available on local index server
   IndexServerAdmin := TAdminIndexServer.Create(nil);
   //Check if the server is running.
   CheckBox1.Checked := IndexServerAdmin.IsRunning;
   if IndexServerAdmin.FindFirstCatalog then
      begin
         CatAdm := TCatAdm.Create(nil);
         CatAdm.ConnectTo(IndexServerAdmin.GetCatalog() as ICatAdm);
         //Add catalog name to the ListBox.
         ListBox1.Items.Add(CatAdm.CatalogName);
         CatAdm.Free;
         while IndexServerAdmin.FindNextCatalog do
            begin
               CatAdm := TCatAdm.Create(nil);
               CatAdm.ConnectTo(IndexServerAdmin.GetCatalog() as ICatAdm);
               //Add catalog name to the ListBox.
               ListBox1.Items.Add(CatAdm.CatalogName);
               CatAdm.Free;
            end;
      end;
   IndexServerAdmin.Free;

end;

procedure TForm1.Button1Click(Sender: TObject);
var
   i, ii: Integer;
   ds: TADODataSet;
   rs: _Recordset; //Defined in ADOdb unit
begin
  IndexQuery.Reset ;
   //Enter query text or just a word in Edit1
   IndexQuery.Query := '$contents "' + Edit1.Text + '"';
   //List fields you want the query to return
   IndexQuery.Columns := 'DocTitle,Path,Write,Rank';
   //Define query result sort order
   IndexQuery.SortBy := 'Rank [d]';
   IndexQuery.MaxRecords := 10000;
   //Catalog selcted in Listbox1
   IndexQuery.Catalog := ListBox1.Items[ListBox1.ItemIndex];
   Memo1.Lines.Clear;
   //Output simple status report
   Memo1.Lines.Add( 'Searching for ' + IndexQuery.Query + ' in "' + IndexQuery.Catalog + '"');
   try
      ds := TADODataSet.Create(nil);
      //Retrieving query results - the trickiest part.
      ds.RecordSet := (IndexQuery.CreateRecordset('nonsequential') as _Recordset);
      ii := ds.Recordset.RecordCount - 1;
      memo1.Lines.Add('num of docs: ' + IntToStr(ii));
   except
      memo1.Lines.Add('did not work on "' + IndexQuery.Catalog + '"');
   end;
   //Assign Recordset object to ADODataSet's RecordSet property.
   ADODataSet1.RecordSet := ds.Recordset;
   ds.Close;
   ds.Free;

end;
it works fine . but my problem is that i want to use the index server
on another machine via network.
I used this code:
IndexServerAdmin:= 'server02'; I saw all catalog in Server02 but when i want to search my keywqords an exception raised:
There is no Catalog.

what can i do?

sorry for my poor german and english
best regards
apolon

[edit=sakura] Replaced [code] with [delphi] Mfg, sakura[/edit]
some men are born to be heroes
  Mit Zitat antworten Zitat