Introduction
Microsoft Indexing service is like, it is making
catalog for storing index of documents. and when we are searching from
using Indexing service it will use those indexes which are stored into
catalog, and will do search very much faster.
So here i will try to explain how we can use this Microsoft Indexing Service.
Using the code
First, we have to configure our Microsoft Indexing service to use it.
install Microsoft indexing service from the Add/Remove utility from control panel...
choose Add/Remove Windows Component --> and select Microsoft Indexing Service and install it.
Now write mmc in Start --> Run,
you will find one window which is said "Microsoft Management Console".
no do this procedure..
Click on File -->ADd/Remove Snap-in --> Add -- > select "Indexing Serivce" then --> ok --> finish.
you will see like following window..
now you have to create one catalog, which will keep track of you directory which you want to search in.
to create catalog click on "Indexing Service on Local Machine" then,
Action --> New - > catalog
Enter Name of catalog and path where you want to save the catalog files.
Your newly created catalog will be there in tree,
no just expand that node and you will see "Directories", now right click on it and select "New" --> "Directory"
Enter the path of irectory which holds your documents in which you want to perform searching operation.
Now Stop and then Start the Indexing Service, it's all, your indexing service is ready to use with your application.
System.Data.OleDb.OleDbConnection odbSearch;
System.Data.OleDb.OleDbCommand cmdSearch;
odbSearch = new System.Data.OleDb.OleDbConnection
("Provider=\"MSIDXS.1\";Data Source=MyDocs;Integrated Security .=");
cmdSearch = new System.Data.OleDb.OleDbCommand();
cmdSearch.Connection = odbSearch;
cmdSearch.CommandText =
"select doctitle, filename, vpath, rank, characterization from scope()
where FREETEXT(Contents, '" + strSearch + "') order by rank desc ";
odbSearch.Open();
OleDbDataAdapter adpt = new OleDbDataAdapter(cmdSearch);
cmdSearch.ExecuteNonQuery();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
adpt.Fill(ds, "SearchResult");
dt = ds.Tables[0];
History
This Process will search only .doc,.txt, .xls files only,
For making it working for .pdf, you have to download Adobe iFilter 6.0 and simply install it.