Introduction If you have come to this article without reading the Part 1, please check Part 1
Once you have created the Catalog for your Search, you can use the Catalog for searching.
Using the Catalog in your Application
1. In your Search Page, have a Textbox (TextBox1) and a Button (Button1).
2. In the click event of the Button, put the following code.
string strCatalog = ;
strQuery = "Select Filename from Scope() where FREETEXT('" + TextBox1.Text + "')";
string connstring = "Provider=MSIDXS.1;Integrated Security .='';Data Source="+ strCatalog;
OleDbConnection objconn = new OleDbConnection(connstring);
OleDbCommand objcmd = new OleDbCommand(strQuery, objconn);
OleDbDataReader objRdr=null; objconn.Open(); objRdr=objcmd.ExecuteReader();
if(objRdr.HasRows) { while(objRdr.Read()) { docname += objRdr["Filename"].ToString() + ","; } docname=docname.Remove(docname.Length-1,1); } }
Now "docname" has a comma separated list of file names containing the search text.
You can have an XML File or a Database table with Nodes/Fields - FileName, a Heading and a Description, which you can use to look up for the document name and get the desired results for displaying in your Page.
This way, you can implement search for your website without writing the logic for search.
This article applies to Windows 2000, Windows XP and Windows 2003
Note: If you would like to search for PDF Files, you need to install the PDF Filter for Indexing Service which helps the Indexing Service in searching within PDF Files. Its a freeware download and can be downloaded from http://www.adobe.com/support/downloads/detail.jsp?ftpID=2611
Summary This completes the 2 part article on implementing search for website documents using Microsoft Indexing Services.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|