Hello All.
I am making a form to search a Microsoft Index Catalog. I am not looking to search the entire web server, just one directory.
I have Indexing turned on, my directory set and the results on the page works properly.
My next step was to create a link to the document based on the search results.
I've toyed with using vpath. I can get vpath results, but they then include other virtual directories I do not want and I can't seem to exclude them from my catalog.
I've toyed with trying to convert the path results to the vpath format. This is where I'm at... I copied the Function VPathToPath from another script which said it would do this, but it does not work with mine. My code is below.
And thanks.
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Search Page</title>
<meta name="description" content="Search Page">
<meta name="keywords" content="Search Page">
<meta name="author" content="John Peterson">
</head>
<body>
<p>
This is the search page of the Allscripts Directory.
</p>
<form action="ExecuteQuery2.asp" method="get">
<input type="text" name="query" />
<input type="submit" value="Search" />
</form>
<%
Dim strQuery ' The text of our query
Dim objQuery ' The index server query object
Dim rstResults ' A recordset of results returned from Allscripts
Dim objField ' Field object for loop
' Retreive the query from the querystring
strQuery = Request.QueryString("query")
' If the query isn't blank then proceed
If strQuery <> "" Then
' Create our index server object
Set objQuery = Server.CreateObject("ixsso.Query")
' Set it's properties
With objQuery
.Catalog = "Allscripts" ' Catalog to query
.Query = strQuery ' Query text
.MaxRecords = 10 ' Max # of records to return
' What to sort records by. I'm sorting by rank [d]
' which is [d]escending by how pertinent Index Server
' thinks the result is. This way the most applicable
' result should be first.
.SortBy = "rank [d]"
' Which columns to return. Column names must
' be the same as the catalog's properties. Some
' of them are: contents, filename, size, path,
' vpath, hitcount, rank, create, write, DocTitle
' DocSubject, DocAuthor, DocKeywords...
.Columns = "filename, path, vpath"
End With
Function PathToVpath(strPath)
Const strWebRoot = "e:\web\
Dim strTemp
strTemp = strPath
strTemp = Replace(strTemp, strWebRoot, "\")
strTemp = Replace(strTemp, "\", "/")
PathToVpath = strTemp
End Function
' 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
' Formatting leaves something to be desired,
' but it'll work for now. We'll pretty things
' up and link to the content in part II.
For Each objField in rstResults.Fields
Response.Write "<strong>"
Response.Write objField.Name
Response.Write ":</strong> "
Response.Write rstResults.Fields(objField.Name)
Response.Write "<br />"
Next
' Spacing between results
Response.Write "<br />"
' Move to next result
rstResults.MoveNext
Loop
End If
' Kill our recordset object
Set rstResults = Nothing
End If
%>
</body>
</html>
I am making a form to search a Microsoft Index Catalog. I am not looking to search the entire web server, just one directory.
I have Indexing turned on, my directory set and the results on the page works properly.
My next step was to create a link to the document based on the search results.
I've toyed with using vpath. I can get vpath results, but they then include other virtual directories I do not want and I can't seem to exclude them from my catalog.
I've toyed with trying to convert the path results to the vpath format. This is where I'm at... I copied the Function VPathToPath from another script which said it would do this, but it does not work with mine. My code is below.
And thanks.
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Search Page</title>
<meta name="description" content="Search Page">
<meta name="keywords" content="Search Page">
<meta name="author" content="John Peterson">
</head>
<body>
<p>
This is the search page of the Allscripts Directory.
</p>
<form action="ExecuteQuery2.asp" method="get">
<input type="text" name="query" />
<input type="submit" value="Search" />
</form>
<%
Dim strQuery ' The text of our query
Dim objQuery ' The index server query object
Dim rstResults ' A recordset of results returned from Allscripts
Dim objField ' Field object for loop
' Retreive the query from the querystring
strQuery = Request.QueryString("query")
' If the query isn't blank then proceed
If strQuery <> "" Then
' Create our index server object
Set objQuery = Server.CreateObject("ixsso.Query")
' Set it's properties
With objQuery
.Catalog = "Allscripts" ' Catalog to query
.Query = strQuery ' Query text
.MaxRecords = 10 ' Max # of records to return
' What to sort records by. I'm sorting by rank [d]
' which is [d]escending by how pertinent Index Server
' thinks the result is. This way the most applicable
' result should be first.
.SortBy = "rank [d]"
' Which columns to return. Column names must
' be the same as the catalog's properties. Some
' of them are: contents, filename, size, path,
' vpath, hitcount, rank, create, write, DocTitle
' DocSubject, DocAuthor, DocKeywords...
.Columns = "filename, path, vpath"
End With
Function PathToVpath(strPath)
Const strWebRoot = "e:\web\
Dim strTemp
strTemp = strPath
strTemp = Replace(strTemp, strWebRoot, "\")
strTemp = Replace(strTemp, "\", "/")
PathToVpath = strTemp
End Function
' 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
' Formatting leaves something to be desired,
' but it'll work for now. We'll pretty things
' up and link to the content in part II.
For Each objField in rstResults.Fields
Response.Write "<strong>"
Response.Write objField.Name
Response.Write ":</strong> "
Response.Write rstResults.Fields(objField.Name)
Response.Write "<br />"
Next
' Spacing between results
Response.Write "<br />"
' Move to next result
rstResults.MoveNext
Loop
End If
' Kill our recordset object
Set rstResults = Nothing
End If
%>
</body>
</html>