The ASP.NET page contains two web controls. A label control
called LabelNumberOfResults is used to display the number of search results. It
is also used to display an errors encountered during a search.
The page also contains a DataGrid control called
DataGridSearchResults. This control is used to display the search results.
There are columns within this DataGrid for displaying a document's rank, its
title and the date the document was last updated. The title is a hyperlink to
the actual document itself.
Note that further columns can of course be added if other
document properties need to be displayed. Although a DataGrid is used in this
example, other web controls can be useful for displaying search results - in
some cases it would be appropriate to use the Repeater control for example.
The sample search does not contain a form for a user to
enter a search query - for now the query is held within the C#'s QueryText
string variable. This value could of course be assigned using the value of a
The name of the Indexing Service search catalog is contained
in the CatalogName variable.
The document rank returned by the Windows Indexing Service
has a value of between 0 and 1000 (with 1000 being the most closely matching
document). The sample C# code reduces this to a figure between 0 and 10, which
then allows the rank of each document to be shown graphically through a set of
images with the filenames 0bars.png to 10bars.png inclusive.
Ordering Search Results
It is useful to be able to order search results. One way of
achieving this would be to create a DataView from the search results data, and
use that to populate the DataGrid:
//Create a DataView from the search results data
DataView SearchDataView = new DataView(SearchResultsTable.Tables);
//Sort the search results by rank
SearchDataView.Sort = "PageRank DESC";
DataGridSearchResults.DataSource = SearchDataView;
Finally, if you are interested in extending the
functionality of Indexing Services to allow content on any web server or ODBC
database to be indexed and searchable, then take a look at the Indexing Service
Companion utility I wrote: http://www.winnershtriangle.com/w/Products.IndexingServiceCompanion.asp.