Monday, August 6, 2007

Searching Your Website with Microsoft Index Service using ASP.NET

Searching Your Website with Microsoft Index Service using ASP.NET

Once a website grows beyond a couple of dozen pages then it can sometimes be difficult to create a site navigation scheme that allows users to quickly find exactly what they're looking for. One way to improve site navigation is to add a search facility to the website. Adding a search facility brings major benefits to a website, making it easier for users to find information as well as adding an additional method of navigating a website. Search facilities are generally well used, and will often appear within the requested pages on a website.

There are different software solutions are available to put your own search engine on your website. Server-side search solutions available such as Microsoft's Index Server or ht://Dig. Although they allow sophisticated search facilities to be created, they generally require a high level of technical knowledge to install and configure. Also you can use the third party components for your website to do the search.

Using Microsoft Index Service it indexes your entire website quickly and generates an efficient search engine. It makes easier for your visitors to find things on your website and gives it a more professional appearance.

What is the Indexing Service?

Microsoft Indexing Service is a service that provides a means of quickly searching for files on the machine. The most familiar usage of the service is on web servers, where it provides the functionality behind site searches. It is built into Windows 2000 and 2003. It provides a straightforward way to index and search your web site.

With Index Services you can specify a specific group of documents or HTML pages to be indexed, and then create an ASP.NET page that can query this index. We'll build a simple, fast, and extensible search tool using .NET and Microsoft Indexing Services, which allows MS Indexing Services to index pages and display them in your search results.

Configuring Microsoft Indexing Services

The first step in creating an index for your search application is to configure Indexing Services on the IIS server that your Web application will be running. To do this you need access to the Web server itself. Open the Microsoft management console by clicking Start, then Run; type mmc and click Ok. Next, to open the Indexing Services snap-in, you must:

Click file,
Click Add/Remove Snap-In,


Click Add,

Select the Indexing Service Snap-In,

Click Add,
Click Finish,

Close the dialog


To create a new catalog - which is the vernacular Microsoft uses for an index - right-click on the Indexing Service node, click New and then Catalog. We need to choose a location to store the catalog file.


Once we done that, expand the catalog that you just created and click on the directories icon. Right-click on the directories folder, click new directory, and add the directory or directories that contain the content that you want to search. These directories can reside anywhere that the host computer can access, virtual directories and even UNC paths (\\Server\share) may be used. However, each directory that is indexed must either reside physically, or be included as a virtual directory, in the root of the website that you are indexing. If a directory is specified that is not in the web root via a physical folder or virtual directory, the results will be displayed in your search, but they will return broken links.

Indexing Services will effectively index HTML documents. To ensure that your required directories will be indexed you should verify that the index flag is properly set on the files and folders. We can verify this setting by right clicking on any folder or file and selecting properties. Click the "Advanced button" and make sure that the "For fast searching, allow indexing services to index this folder" checkbox is checked.

Next, you want to set the properties of this catalog so that the HTML paths can be used, and so that Indexing Services will generate abstracts for the documents as they are indexed.

To do this right-click on the catalog you just created and select Properties. On the tracking tab, you'll need to make sure that the "WWW Server:" field is set to the website that your application will be running from. This ensures that the html paths work as they should when you get to building the front-end for the search. If you want to display a short bit of each article along with your search results, then go to the Generation tab, uncheck "inherit above settings from service, then check “generate abstracts” and set the number of characters you wish to have displayed in each abstract.



Generally index will include one folder of documents or an entire website or group of websites. It's up to us to determine the breadth of the index. However, since Index Services does not crawl links like a spider, it will only catalog file system objects. Thus, the results from this search will include static files such as HTML pages, Word documents, but not any dynamically generated pages. Changes made to these static documents will be picked up by Indexing Services and will very quickly be reflected in your search results.


Searching the Index

Once the index has been created, the next step is to build a search page that allows the website visitor to search through the index. To do this, we have to create a TextBox Web control for the end user to enter search terms, and a Button Web control to initiate the search, and a Repeater control to display the results.

Add the following code in the .aspx page:

more :

http://www.developeriq.com/articles/2007/aug/06/searching-your-website-microsoft-index-service-usi/


Save the project and run.


The fields returned from querying the index include the following information.

tags in an HTML document or the text in the title field of a word document.The title of document, which is the text between the
Filename: The physical name of the file that the result was returned from.
Vpath: The virtual path of the file where the result was returned from. This is the field you use to specify an HTML link to the file.
Rank: The relevance of the returned result.
Characterization: The abstract for the document, usually the first 320 characters.

Finally we have learnd how to use the Index server to build our Search. For any other queries you can reach me on srinivasks_08@yahoo.co.in

No comments: