Click here to Skip to main content
15,881,803 members
Articles / Web Development / ASP.NET
Article

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

Rate me:
Please Sign up or sign in to vote.
1.31/5 (5 votes)
30 Mar 20071 min read 26.3K   11   4
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.

C#
// 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


Written By
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

 
Questionreferences Pin
kiquenet.com9-Jun-16 22:13
professionalkiquenet.com9-Jun-16 22:13 
QuestionToo slow to get the result [modified] Pin
MVini14-Jun-07 8:35
MVini14-Jun-07 8:35 
Thank you for this article.
Does someone know why it becomes too slow to get a big result? I tested the same query in the native search page (in MMC the node Search Catalog) in and it is almost instantaneous, but when using OleDb... too slow. I had a previous page in asp that was satisfying. I just want to convert it to .NET, but my users will get bored.
Thank you.


-- modified at 9:09 Wednesday 20th June, 2007
GeneralTo sum it up Pin
NormDroid31-Mar-07 5:48
professionalNormDroid31-Mar-07 5:48 
GeneralGoogle API Pin
Vasudevan Deepak Kumar31-Mar-07 4:56
Vasudevan Deepak Kumar31-Mar-07 4:56 

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

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