Click here to Skip to main content
Click here to Skip to main content

How to use Microsoft Indexing Service to make search faster...

, 30 Mar 2007
Rate this:
Please Sign up or sign in to vote.
Interface of Microsoft Indexing Service with our application...

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.

// first create the OleDb connection...
System.Data.OleDb.OleDbConnection odbSearch;
System.Data.OleDb.OleDbCommand cmdSearch;
//Then prepare the Connection String to connect with the
//Indexing Server database. 
odbSearch = new System.Data.OleDb.OleDbConnection
    ("Provider=\"MSIDXS.1\";Data Source=MyDocs;Integrated Security .=");

//Instead of "MyDocs" you have to wrtie catalog name which you have created,
//from above process.

cmdSearch = new System.Data.OleDb.OleDbCommand();
cmdSearch.Connection = odbSearch;
 
//Now Prepare the Command Text.
cmdSearch.CommandText = 
"select doctitle, filename, vpath, rank, characterization from scope() 
where FREETEXT(Contents, '" + strSearch + "') order by rank desc ";
//Now Open the Connection.
odbSearch.Open();
//Now Fire the command.
OleDbDataAdapter adpt = new OleDbDataAdapter(cmdSearch);
                
cmdSearch.ExecuteNonQuery();

DataSet ds = new DataSet();
DataTable dt = new DataTable();
                              
adpt.Fill(ds, "SearchResult");
dt = ds.Tables[0];
 
//Thats it, DataTable "dt" will hold your Search Result you can use it now.

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

JustChiragPatel
Software Developer
India India
Chirag Patel, a Programmer Analyst in a well known IT company working on .NET Technologies since last 2 years. He is interested in Pure business logic and fuzzy logic. his area of interest is in C#.NET, VB.NET and MSSQL 2005.
 
catch me on: http://groups.google.com/group/codewar

Comments and Discussions

 
QuestionToo slow to get the result [modified] PinmemberMVini14-Jun-07 8:35 
GeneralTo sum it up Pinmembernorm .net31-Mar-07 5:48 
GeneralGoogle API PinmemberVasudevan Deepak Kumar31-Mar-07 4:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141030.1 | Last Updated 31 Mar 2007
Article Copyright 2007 by JustChiragPatel
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid