Author: Massimo Brini
Many people has asked how to search inside an index server from Microsoft in order
to show the results like a normal dataset. Here's how this can be done and some
considerations on the use & misuse of this technology
Answer:
What is Index Server
Index Server is the web-based solution choosen by Microsoft to give its IIS server
the ability to search and retrieve documents; as it is concieved for use with ASP
pages, it is strongly based on COM technology and in its latest release has been
fully integrated also with the ADO technology.
First Steps
I will demonstrate how to leverage on ADO in order to search the directories of the
default catalog of the main website; to search another catalog you will just change
an option.
First of all you should get the Microsoft primer on Index Server at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnindex/html/msdn_i
s-intro.asphttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnindex/
html/msdn_is-intro.asp
With this link you wil lfind the explanation necessary to use the index server;
using it is anyway easy.
To start it just go inside the Microsoft Management Console (MMC) and open inside
it the services; the Microsoft Index Server Service is listed here, just right
click to view the contextual menu and choose from it the "Start" option; if you
want you can have it start automatically on every boot, just choose the properties
of the listed item and choose "Auto Start" from the combo box.
You can have more than 1 catalog to search within; top add new catalogues you
should open the MMC for IIS and work from it, but remember that this works only
with Nt4/W2K server, not workstation, as in Nt4/W2K wkst only 1 web site is
allowed.
BTW: The default catalog is named "WEB".
ADO integration
Let's get our feet wet... We will build a form with a text field and a db grid in
which you will see the results of your search, just like using a normal database
like access or sql server
First of all open a brand new Delphi Project; add a ADQuery & ADOConncetion couple
on the form, together with a Datasource and a DBGrid. You will also need a button
and a Edit component.
After these veru first steps, double click on the connectionstring property of the
ADOCOnnection1 component; it will open the standard box; from the list of OLEDB
Providers you should find (if your ADO is up to date) choose:
"Microsoft OleDb Provider for Indexing Services"; with a double click you will have
access to the advanced options, which are already setted correctly; if you want to
change the catalogue, just modify the text in the "data source" field. Click on
"Test connection", everything should work.
Connect together as usual the components:
Adoquery1 -> Adoconnection1
Datasource1 -> Adoquery1
DBGRID1 -> Datasource1
I suggest of course to keep Adoconnection1.loginprompt := False and to open the
connection asap (I made this at design time).
and then double click on th Button you already placed on the form in the first
step; the event handler is as follows, just copy and paste:
1 var
2 tmp: string;
3 begin
4 if ADOQuery2.active then
5 ADOQuery2.close;
6 tmp := 'Select DocTitle, path, rank, size, Vpath, write FROM scope() WHERE
7 CONTAINS('ext + ''') > 0 ORDER by FileName';
8 ADOQuery2.sql.text := tmp;
9 ADOQuery2.Open;
10 end;
now you have finished: just run the application and type "note" inside the text
field, it should show you 3/4 records inside the dbgrid, with the records showing
the file names, path etc etc.
Pros & Cons
PROS
You can integrate searched made on Index server and other data repositories like
Access files... this can be very useful for sites based upon dynamic page creation
technology.
Zero administration
Perfect for ASP objects made in Delphi and for CGIs
CONS
First of all there is a bug in the ADOQuery implementation by Borland, changing the
SQL property of the ADOQUERY may result in error messages at design time; it is a
confirmed bug, anyway everything works perfectly on runtime. So don't worry for
this; maybe a patch will be given to Delphi user, otherwise you can try other ways
(Using native ADO as COM objects resolve the problem)
Second: Index Server is tigtly integrated with IIS so you can search only web
catalogues, not particular directories of you file system.
Component Download: http://www.dreamscapeitalia.com/download/delphi_index_server.zip
|