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;