Microsoft's Internet Information Server using Index Server is ideal for Web sites where static content is stored on the file system. Learn how to use it.

Any Web site running Microsoft's Internet Information Server (IIS) can use the Index Server search engine that comes with IIS. Adding a search engine to your Web site can be easy with Index Server, if your site's content is contained in a directory on the file system. Index Server doesn't use a Web spider or crawler like Google or other search engines—instead it loads all of the content under a directory. Index Server uses the file system security that's built into the NTFS file system to restrict access to documents that have been indexed.

Index Server has several advantages: It's free, it supports multiple languages with stemming, and it can index both Microsoft Office documents and HTML files. Developers can add additional file formats to the indexer by writing a text conversion tool that implements the IFilter interface.

Two disadvantages of using Index Server are that it doesn't have built-in support for indexing dynamic content, and it can index only the contents of one machine—if your Web site includes Web servers with different content, you can't use Index Server to implement a global search facility. To support a multi-server search, use a search engine that supports spiders or crawling, such as most of the commercial search solutions. If you have any database-driven content, you will have to generate static pages for your data and index them.

Running Index Server
Index Server runs as a service on your Windows Web server. All of the following directions are given for Windows 2000, but other versions of Windows will be very similar. To begin, open Control Panel, open the Services control panel under Administrative Tools, and start the Indexing Service if it's not already running. If you don't have Index Server installed, it can be added through the Add/Remove Programs control panel as a Windows component.

Creating a catalog
Once you have the indexing service started, you can create a catalog for your Index Server. A catalog is a collection of documents that corresponds to a directory on the file system. To manage Index Server, use the Microsoft Management Console (MMC) Computer Management snap-in, which is also located in the Administrative Tools folder. The Computer Management snap-in is shown in Figure A.


Figure A
The Computer Management snap-in provides an interface for managing the indexing service.


Under Services And Applications in the snap-in, select the Indexing Service. You'll create your catalog here. Right-click Indexing Service, and select New | Catalog. The Add Catalog dialog box will open. Give your catalog the name Example, and the search index will be C:\TEMP\SEARCH.

Index Server can work with IIS to add the virtual path to your content to the index, so you can create links right out of IIS. You need to associate the IIS Web site with your catalog so Index Server can pick up on the virtual directory being used. Right-click the Example catalog in either pane, and select Properties. Select the Tracking tab of the Example Properties dialog box that appears, as shown in Figure B. For WWW Server, choose Default Web Site, or whatever your IIS installation is called.

Figure B
Choose your IIS installation through the Tracking tab.


When you go back to the Computer Management MMC snap-in, you'll see that the Example catalog is ready to be indexed, but it doesn't have any content assigned yet. By putting the content in C:\TEMP\CONTENT, you make it accessible through IIS as the virtual directory content. Add it to the catalog as a directory—each catalog can have multiple directories of content to index. Right-click the Directories folder under the Example catalog in the left hand pane, and select New | Directory.

Figure C shows the built-in query page that comes with the Index Server snap-in. I searched for the word "example," and got three hits, so I can tell my catalog was created properly.

Figure C
The Index Server snap-in offers this built-in query page.


Writing a search page
Index Server comes with a component for running queries inside an ASP page. Another approach would be to use Active Data Objects (ADO) directly to access the index server in a similar manner as a database. Use the Index Server Query object, which has a ProgID of ixsso.Query.

Set up a standard ASP page (shown in Listing A), with a form that will always appear at the top, and results that show up only if the form has been submitted. Check to see if the searchPhrase variable is in the Request's QueryString. To get the results, create an instance of the Query object with Server.CreateObject("ixsso.Query") in the ASP.

Next, set up the Query object by setting its properties. The properties on the Query object you're going to use are:
  • Catalog—The name of the Catalog you set up in the Index Server.
  • Columns—A comma-delimited list of the columns you're going to get back, similar to a SQL query. Some available columns include: filename, vpath (virtual path on the Web server for the file), path (on the file system), DocAuthor, DocCharCount, DocTitle, DocWordCount, hitcount, rank (Index Server ranks each hit by how closely it matches the search terms), size (size of the document on disk), and write (timestamp of document's last modified time).
  • MaxRecords—The maximum number of records the query will return.
  • Query—The query the user searched for. It can be simple, or it can be written using the Index Server query language, which uses Boolean operators. (These operators include AND, OR, NOT, and NEAR.)
  • SortBy—The column that Index Server should use to sort the results. This property takes the form columnName[a] or columnName[d] for ascending and descending. (Typically you'll use rank[d] to sort the query results by relevance, in descending order.)

You'll get the query from the form, and the other properties are going to be hard coded in the ASP. After you set the properties, create a RecordSet object from the Query, which tells IndexServer to execute the query and return a set of search results with the columns you wanted. It's very similar to executing a SELECT statement on a relational database and getting a set of results back from a table. You'll use this line of code:
Set objRecordSet = objQuery.CreateRecordSet("nonsequential")

You created the record set with the nonsequential cursorType parameter. You could have also used a sequential cursor, but that would be efficient only for forward scrolling in the results if you had a paged search results set.

Search solution on a budget
For Web sites built on IIS that don't have a large budget for a search solution, Microsoft's Index Server provides excellent functionality with a small investment of time. With its GUI catalog administration and use of ASP and ADO syntax, most Microsoft ASP developers should consider Index Server as a solution for most small and midsize projects where static content is stored on the file system.

Do you need help with Web Technologies? Gain advice from Builder AU forums

Related links

Comments

1

An - 01/03/05

Hi how can i add Catalog and Directory to Indexing Service
from .Net application

» Report offensive content

2

Hi - 03/07/08

I tried to implement indexing service on my site exvery thing is working but path is not coming


only web site name is comg virtual path is coming blank ..
virtualpath = RSSearchResult("vpath") ' mm: vpath is not returned by default. Few settings have to be done in the Catalog for this..
'Response.Write "<br>virtualpath" & virtualpath
virtualpath = "http://example/" & virtualpath

<HTML>
<HEAD>
<TITLE>Index Server Search Result Form</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
</HEAD>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
<body>
<%
Dim NewQuery
Dim UseSavedQuery
Dim SearchString
Dim FileNExactBox
Dim PageNumber
Dim NextPageNumber
Dim NextRecordNumber
Dim objQuery
Dim objUtil
Dim RSSearchResult
Dim ActiveQuery
Dim LastRecordOnPage
Dim CurrentPage
Dim virtualpath
Dim SaveQuery
Dim NextString
Dim NextSet
%>

<%
NewQuery = FALSE
UseSavedQuery = FALSE
SearchString = ""

if Request.ServerVariables("REQUEST_METHOD") = "POST" then
SearchString = Trim(Request.Form("SearchString"))
Response.Write "<br>SearchString---" & SearchString
FileNExactBox = Request.Form("chkExactFileName")
PageNumber = Request.Form("PageNumber")

if PageNumber <> "" then
NextPageNumber = PageNumber
NewQuery = FALSE
UseSavedQuery = TRUE
else
NewQuery = SearchString <> ""
end if
end if

%>
<p>
<%
if SearchString <> "" then
if NewQuery then
set Session("Query") = nothing
set Session("Recordset") = nothing
NextRecordNumber = 1

set objQuery = Server.CreateObject("ixsso.Query")
objQuery.Catalog = "BPOWEBPROD123" ' mm: This should be changed appropriately while deploying elsewhere


'Response.Write "<BR>objQuery.Catalog----" & objQuery.Catalog
set objUtil = Server.CreateObject("ixsso.util")
Err.number = 0

' mm: Important QUERY used for RESTRICTING the result set----->

IF FileNExactBox = "FileName" THEN
objQuery.Query = "(#filename *.asp OR *.doc OR *.txt OR *.zip OR *.pdf OR *.xls) AND (NOT #vpath *\includes*) AND (NOT #vpath *\images*) AND (#filename " & SearchString & ".*)"
ELSEIF FileNExactBox = "Exact" THEN
objQuery.Query = "(#filename *.asp OR *.doc OR *.txt OR *.zip OR *.pdf OR *.xls) AND (NOT #vpath *\includes*) AND (NOT #vpath *\images*) AND (@contents " & SearchString & ")"
ELSE
objQuery.Query = "(#filename *.asp OR *.doc OR *.txt OR *.zip OR *.pdf OR *.xls) AND (NOT #vpath *\includes*) AND (NOT #vpath *\images*) AND (" & SearchString & ")"
END IF

objQuery.SortBy = "rank[d]"
objQuery.Columns = "DocTitle, vpath, path, filename, size, write, characterization"

'Response.Write "<br>vpath --" & vpath
'Response.Write "<br>path --" & path


objUtil.AddScopeToQuery objQuery, "c:\bpo", "shallow"
objUtil.AddScopeToQuery objQuery, "c:\bpo\communication", "deep"




'on error resume next
set RSSearchResult = objQuery.CreateRecordSet("nonsequential")
if Err.number <> 0 then
Response.Write("The search text <html><font face=Arial color=#0000ff><b>" & SearchString & "</b></font></html> is not allowed")
else
RSSearchResult.PageSize = 10
ActiveQuery = TRUE
end if

elseif UseSavedQuery then
if IsObject( Session("Query") ) And IsObject( Session("RecordSet") ) then
set objQuery = Session("Query")
set RSSearchResult = Session("RecordSet")

if RSSearchResult.RecordCount <> -1 and NextPageNumber <> -1 then
RSSearchResult.AbsolutePage = NextPageNumber
NextRecordNumber = RSSearchResult.AbsolutePosition
end if

ActiveQuery = TRUE
else
Response.Write "ERROR - No saved query"
end if
end if

if ActiveQuery then
if not RSSearchResult.EOF then
LastRecordOnPage = NextRecordNumber + RSSearchResult.PageSize - 1
CurrentPage = RSSearchResult.AbsolutePage
if RSSearchResult.RecordCount <> -1 AND RSSearchResult.RecordCount < LastRecordOnPage then
LastRecordOnPage = RSSearchResult.RecordCount
end if
Response.Write "<span class='text_bold'>Documents " & NextRecordNumber & " to " & LastRecordOnPage
if RSSearchResult.RecordCount <> -1 then
Response.Write " of " & RSSearchResult.RecordCount
end if
Response.Write " matching the query " & chr(34) & "<I>"
Response.Write SearchString & "</I>" & chr(34) & ".<P></span>"
%>
<dl>
<!-- BEGIN first row of query results table -->
<% Do While Not RSSearchResult.EOF and NextRecordNumber <= LastRecordOnPage %>
<%
virtualpath = RSSearchResult("vpath") ' mm: vpath is not returned by default. Few settings have to be done in the Catalog for this..
'Response.Write "<br>virtualpath" & virtualpath
virtualpath = "http://www.coverlettersonline.com" & virtualpath ' mm: This should be changed appropriately while deploying elsewhere
%>
<p>
<dt><span class="text">

<!-- <%= NextRecordNumber%>
. </span><span class="text_blue"><%if RSSearchResult("DocTitle") <> "" then%> <%= RSSearchResult("DocTitle")%> <%else%> <%= RSSearchResult("filename")%> <%end if%> - </span><span class="text"><a href="<%=virtualpath%>" target=_blank"><%=virtualpath%></a></span>
-->

<%= NextRecordNumber%>
. </span><span class="text_blue"><%= RSSearchResult("DocTitle")%> - </span><span class="text"><a href="<%=virtualpath%>" target=_blank"><%=virtualpath%></a></span>
<dd>
<%
RSSearchResult.MoveNext
NextRecordNumber = NextRecordNumber+1
Loop
%>
</dd>
</dl>
<P><BR>
<%
else ' NOT RSSearchResult.EOF
if NextRecordNumber = 1 then
Response.Write "<span class='text_bold'>No documents matched the query<P></span>"
else
Response.Write "<span class='text_bold'>No more documents in the query<P></span>"
end if

end if ' NOT RSSearchResult.EOF
%>
<!-- If the index is out of date, display the fact -->
<%if objQuery.OutOfDate then%>
<P><I><B><span class="text_bold">The index is out of date.</span></B></I><BR>
<%end if%>
<!--
If the query was not executed because it needed to enumerate to
resolve the query instead of using the index, but AllowEnumeration
was FALSE, let the user know
-->
<%if objQuery.QueryIncomplete then%>
<P><I><B><span class="text_bold">The query is too expensive to complete.</span></B></I><BR>
<%end if%>
<!--
If the query took too long to execute (for example, if too much work
was required to resolve the query), let the user know
-->
<%if objQuery.QueryTimedOut then%>
<P><I><B><span class="text_bold">The query took too long to complete.</span></B></I><BR>
<%end if%>
<TABLE id="Table1">
<!--
This is the "previous" button.
This retrieves the previous page of documents for the query.
-->
<%SaveQuery = FALSE%>
<%if CurrentPage > 1 and RSSearchResult.RecordCount <> -1 then %>
<TR>
<td align="left">
<form action="SearchResultBPO.asp" method="post">
<INPUT id=hdnSearchString1 type=hidden value="<%=SearchString%>" name=SearchString>
<INPUT id=hdnSearchString2 type=hidden value="<%=CurrentPage-1%>" name=PageNumber>
<input type="submit" value="Previous <%=RSSearchResult.PageSize%> documents" ID="btnSubmitPrevious" NAME="btnSubmitPrevious">
</form>
</td>
<%SaveQuery = TRUE%>
<%end if%>
<!--
This is the "next" button.
This button retrieves the next page of documents for the query.
If the RSSearchResult.RecordCount is available, the number of
documents on the next page will be displayed.
-->
<%if Not RSSearchResult.EOF then%>
<td align="right">
<form id="Form1" action="SearchResultBPO.asp" method="post">
<INPUT id=hdnSearchString3 type=hidden value="<%=SearchString%>" name=SearchString>
<INPUT id=hdnSearchString4 type=hidden value="<%=CurrentPage+1%>" name=PageNumber>
<% NextString = "Next "
if RSSearchResult.RecordCount <> -1 then
NextSet = (RSSearchResult.RecordCount - NextRecordNumber) + 1
if NextSet > RSSearchResult.PageSize then
NextSet = RSSearchResult.PageSize
end if
NextString = NextString & NextSet & " documents"
else
NextString = NextString & " page of documents"
end if
%>
<input type="submit" value="<%=NextString%>" ID="btnSubmitNext" NAME="btnSubmitNext">
</form>
</td>
<%SaveQuery = TRUE%>
<%end if%>
</TR>
</TABLE>
<%if RSSearchResult.PageCount <> 0 then%>
<!-- Display the page number --><span class="text_bold"> Page
<%=CurrentPage%>
<%if RSSearchResult.PageCount <> -1 then
Response.Write " of " & RSSearchResult.PageCount
end if %> </span>
<%end if%>
<%
' If either of the previous or back buttons were displayed, save the query
' and the recordset in session variables.
if SaveQuery then
set Session("Query") = objQuery
set Session("RecordSet") = RSSearchResult
'Response.Write "<br> RSSearchResult" & RSSearchResult
else
RSSearchResult.close
Set RSSearchResult = Nothing
Set objQuery = Nothing
set Session("Query") = Nothing
set Session("RecordSet") = Nothing
end if
%>
<% end if

elseif not NewQuery then
Response.Write ""
else
Response.Write "Please enter a word or phrase to search for."
end if

%>
</P>
</body>
</HTML>

» Report offensive content

3

nano rycy - 29/04/09

Flobo Recovery is the leading provider of powerful data
recovery, drive image, HDD repair and PC privacy utilities
for the Windows OS family. All Flobo software titles are
listed below.Trial versions of each program can be
downloaded free of charge by using the Download link above
or the FREE Trial link listed with each product. Use the
Buy It! link to securely purchase any Flobo product and
download right to your desktop

» Report offensive content

4

sujan - 12/02/10

can i search pdf documents also??
I want abstract, author,title and content in the pdf document ..
Is it possible to extract this by using asp &IIs &windows xp

..............

» Report offensive content

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

4

sujan - 02/12/10

can i search pdf documents also?? I want abstract, author,title and content in the pdf document .. Is it possible to extract this ... more

3

nano rycy - 29/04/09

Flobo Recovery is the leading provider of powerful data recovery, drive image, HDD repair and PC privacy utilities for the Windows OS family. ... more

2

Hi - 07/03/08

I tried to implement indexing service on my site exvery thing is working but path is not coming only web ... more

Log in


Sign up | Forgot your password?

  • Staff Microsoft shows off IE9 preview

    This week, highlights from Microsoft's MIX10 conference and more in the Roundup. Read more »

    -- posted by Staff

  • Chris Duckett IE9's H.264 vote killed Ogg

    In a split decision by the judges, the winner of the W3C/WHATWG video codec consensus is H.264, taking home the future of video playback on the internet while loser Ogg goes home with nothing but thoughts of what might have been. Read more »

    -- posted by Chris Duckett

  • Staff Google launches Apps Marketplace

    Google launches and app store, while Mozilla plans to re-write its open-source license. More of this week's news in the Roundup. Read more »

    -- posted by Staff

What's on?

  • Optus Deal

    Broadband + home phone + PlayStation®3 in a single package price!