Fejl i søgeformular til Indexing Services
Formularen virker ok, når jeg udkommenterer objUtility.AddScopeToQuery. Så søges på hele webstedet, men jeg vil gerne søge i en specifik mappe, som jeg kalder 'doc'. Kan nogen se, hvorfor det ikke virker, når jeg tilføjer et scope. Jeg får ingen fejlmelding, men bare beskeden 'No results found' til trods for, at jeg søger på noget, som med sikkerhed ligger i 'doc'<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>ASP 101's Index Server Article - Advanced Search Page</title>
<meta name="description" content="ASP 101's Index Server Article - Advanced Search Page">
<meta name="keywords" content="ASP 101's Index Server Article - Advanced Search Page">
<meta name="author" content="John Peterson">
</head>
<body>
<p>
This is the advanced search page of the sample web content
for ASP 101's Index Server article.
</p>
<form action="advanced.asp" method="get">
<input type="text" name="query" />
<input type="submit" value="Search" />
</form>
<p>
<a href="../default.asp">Basic Search</a>
</p>
<p>
Queries that should return results include:
<a href="advanced.asp?query=admin">admin</a> (only in basic),
<a href="advanced.asp?query=asp">asp</a> (> 10),
<a href="advanced.asp?query=component">component</a>,
<a href="advanced.asp?query=cookie">cookie</a>,
<a href="advanced.asp?query=database">database</a>,
<a href="advanced.asp?query=date">date</a>,
<a href="advanced.asp?query=time">time</a>,
<a href="advanced.asp?query=email">email</a>,
<a href="advanced.asp?query=form">form</a>,
<a href="advanced.asp?query=search">search</a>,
etc.
</p>
<%
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 = "FPSE_search" ' 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\doc", "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 "<p><strong>"
Response.Write rstResults.RecordCount
Response.Write "</strong> results found:</p>"
' Loop through results
Do While Not rstResults.EOF
' Loop through Fields
' Pretty is as pretty does... good enough:
%>
<p>
<% If rstResults.Fields("doctitle") = "" Then %>
<strong><a href="<%= PathToVpath(rstResults.Fields("path")) %>"><%= PathToVpath(rstResults.Fields("path")) %></a></strong><br />
<% Else %>
<strong><a href="<%= PathToVpath(rstResults.Fields("path")) %>"><%= rstResults.Fields("doctitle") %></a></strong><br />
<% End If %>
<em>Author:</em> <%= rstResults.Fields("docauthor") %><br />
<em>Last Modified:</em> <%= rstResults.Fields("write") %><br />
<em>Size:</em> <%= rstResults.Fields("size") %> bytes<br />
<em>Keywords:</em> <%= rstResults.Fields("dockeywords") %><br />
<em>Description:</em> <%= rstResults.Fields("characterization") %><br />
</p>
<hr />
<%
' Move to next result
rstResults.MoveNext
Loop
rstResults.MoveFirst
Response.Write "<pre>"
'Response.Write rstResults.GetString()
Response.Write "</pre>"
End If
' Kill our recordset object
Set rstResults = Nothing
End If
%>
</body>
</html>
<%
Function PathToVpath(strPath)
Const strWebRoot = "c:\inetpub\wwwroot\"
Dim strTemp
strTemp = strPath
strTemp = Replace(strTemp, strWebRoot, "\")
strTemp = Replace(strTemp, "\", "/")
PathToVpath = strTemp
End Function
%>
