using Index Server from within ASP. It assumes you have access to a web server running Internet Information Server 4.0 on Windows NT Server.
1.Creating a search form
The first thing to do is to create a page containing a form in which the user can enter their search word or phrase. You can of course have a combined search form page and search results page, but I prefer to keep them separate.
2.Creating a search results page
The following code can be used for a basic search results page. It should be saved as SearchResults.asp.
The first part of the search results page initialises variables and constants:
<%
Dim sSearchString
Dim oQuery
sSearchString = Request.Form(”query”)
Const SEARCH_CATALOG = “catalog_name”
%>
The search string was posted from the SearchForm.asp search form page, and the word or phrase to be searched for are extracted from the query item in the Request.Form collection.
The SEARCH_CATALOG constant is also defined.This name will vary so you will have to change it. If your site is hosted with a hosting company then they will usually set up a catalog on the Index Server for you, then let you know the name of your search catalog. If you are using your own web server, then you should be able to determine the catalog name from the Index Server Management Console
The next part of the search results page initialises the Index Server Query COM component which enables the search to be performed:
<%
Set oQuery = Server.CreateObject(”IXSSO.Query”)
oQuery.Catalog = SEARCH_CATALOG
oQuery.Query = “@all ” & sSearchString & _
” AND NOT #path *_* AND NOT #path *downloads* ” & _
” AND NOT #path *images* AND NOT #filename *.class ” & _
“AND NOT #filename *.asa AND NOT #filename *.css AND NOT #filename *postinfo.html”
oQuery.MaxRecords = 200
oQuery.SortBy = “rank[d]”
oQuery.Columns = “DocAuthor, vpath, doctitle, FileName, Path, ” & _
“Write, Size, Rank, Create, Characterization, DocCategory”
Set oRS = oQuery.CreateRecordSet(”nonsequential”)
%>
Catalog: The name of the search catalog to be searched.
Query: The query to be made. Note that the query in this example is comprised of the search string, plus a list of file and folder exclusions.
MaxRecords: This property specifies the maximum number of search results that should be returned.
SortBy: This specifies which column name the search results should sorted by. The usual setting for this is rank[d], i.e. sort results in descending order according to their similarilty to the search string.
Columns: A list of column properties that should be returned in the search results.
Finally, an ADO RecordSet is created from the records found for this search.
<%
If oRS.EOF Then
Response.Write “No pages were found for the query ” & sSearchString & “”
Else
Do While Not oRS.EOF
Response.write “FileName: ” & oRS(”FileName”) & ”
”
Response.write “doctitle: ” & oRS(”doctitle”) & ”
”
Response.write “Size: ” & oRS(”Size”) & ”
”
Response.write “Create: ” & oRS(”Create”) & ”
”
Response.write “Write: ” & oRS(”Write”) & ”
”
Response.write “Characterization: ” & oRS(”Characterization”) & “”
oRS.MoveNext
Loop
End If
%>
Posted by
Mahesh ( Tryangled )