%@ Language="VBScript" %> <% Option Explicit %>
This is the advanced search page of the sample web content for ASP 101's Index Server article.
Queries that should return results include: admin (only in basic), asp (> 10), component, cookie, database, date, time, email, form, search, etc.
<% Dim strQuery ' The text of our query Dim objQuery ' The index server query object Dim rstResults ' A recordset of results returned from I.S. Dim objField ' Field object for loop ' Retreive the query from the querystring strQuery = Request.QueryString("query") ' If the query isn't blank them proceed If strQuery <> "" Then ' Create our index server object Set objQuery = Server.CreateObject("IXSSO.Query") ' Set it's properties With objQuery .Catalog = "IS-Sample" ' Catalog to query .MaxRecords = 10 ' Max # of records to return .SortBy = "rank [d]" .Columns = "filename, path, vpath, size, write, " _ & "characterization, DocTitle, DocAuthor, " _ & "DocKeywords, rank, hitcount" ' Build our Query: Hide admin page and FPSE pages strQuery = "(" & strQuery & ")" _ & " AND NOT #filename = *admin*" _ & " AND NOT #path *\_vti_*" ' Uncomment to only look for files modified last 5 days 'strQuery = strQuery & " AND @write > -5d" .Query = strQuery ' Query text End With ' To set more complex scopes we use the utility object. ' You can call AddScopeToQuery as many times as you need to. ' Shallow includes just files in that folder. Deep includes ' subfolders as well. ' 'Dim objUtility 'Set objUtility = Server.CreateObject("IXSSO.Util") 'objUtility.AddScopeToQuery objQuery, "c:\inetpub\wwwroot\indexserver", "shallow" 'objUtility.AddScopeToQuery objQuery, "c:\inetpub\wwwroot\indexserver\content", "shallow" 'Set objUtility = Nothing ' Get a recordset of our results back from Index Server Set rstResults = objQuery.CreateRecordset("nonsequential") ' Get rid of our Query object Set objQuery = Nothing ' Check for no records If rstResults.EOF Then Response.Write "Sorry. No results found." Else ' Print out # of results Response.Write "" Response.Write rstResults.RecordCount Response.Write " results found:
" ' Loop through results Do While Not rstResults.EOF ' Loop through Fields ' Pretty is as pretty does... good enough: %>
<% If rstResults.Fields("doctitle") = "" Then %>
"><%= PathToVpath(rstResults.Fields("path")) %>
<% Else %>
"><%= rstResults.Fields("doctitle") %>
<% End If %>
Author: <%= rstResults.Fields("docauthor") %>
Last Modified: <%= rstResults.Fields("write") %>
Size: <%= rstResults.Fields("size") %> bytes
Keywords: <%= rstResults.Fields("dockeywords") %>
Description: <%= rstResults.Fields("characterization") %>
" 'Response.Write rstResults.GetString() Response.Write "" End If ' Kill our recordset object Set rstResults = Nothing End If %> <% Function PathToVpath(strPath) Const strWebRoot = "c:\inetpub\wwwroot\" Dim strTemp strTemp = strPath strTemp = Replace(strTemp, strWebRoot, "\") strTemp = Replace(strTemp, "\", "/") PathToVpath = strTemp End Function %>