% '------------------------------------------------------------------------------------------ ' Page Name: Search.asp ' Author: Martin Stiby ' Synopsis: Site document search. '------------------------------------------------------------------------------------------ ' Date | Author | Version | Reason and Description '------------------------------------------------------------------------------------------ ' 22Feb00 | Martin Stiby | 1.0 | Creation ' 29Feb00 | Brian Southby | 1.1 | Cursor now locates to the search form on load '------------------------------------------------------------------------------------------ 'If the client requests a link, redirect them to that page. if (Request("jump.x") <> "") then Response.Redirect(Request("Index")) end if %> <% ' Customize parameters FormScope = "/" PageSize = 10 SiteLocale = "EN-US" Catalog = "Crossroads" ' Query parameters NewQuery = FALSE UseSavedQuery = FALSE SaveQuery = FALSE AndSaveQuery = FALSE QueryColumns = "DocTitle, vpath, filename, size, write, characterization" ' Here comes the tricky bit. We don't want any FrontPage *vti* directories to be included in the ' search results, or other sensitive files, so "not #VPath |(*vti*|)" ' is added to the query solves this. ' Next, we only want HTM, SHTM or SHTML files to be returned, ' so "and #filename *.|(htm|,shtm|,shtml|)" solves this. ' The "#Path |(*crossroadshospice*|)" ensures that only files with that string in there file path are considered. QueryParameterString = " and not #VPath |(*vti*|) and #Path |(*crossroadshospice.bc.ca*|) and #filename *.|(htm|,shtm|,shtml|)" SearchString = "" QueryForm = Request.ServerVariables("PATH_INFO") ' Three ways of coming in - first display of page, hit "go", or hit prev/next if Request("SearchString").Count <> 0 then ' Not first time in page if Request("pg").Count <> 0 then ' Coming in using prev/next SearchString = Request("SearchString") if Request("pg") <> "" then NextPageNumber = Request("pg") NewQuery = FALSE UseSavedQuery = TRUE else NewQuery = SearchString <> "" end if else ' Coming in via Go! or ENTER key SearchString = Request("SearchString") NewQuery = TRUE end if end if %>
Search Facilities
<% if NewQuery then set Session("Query") = nothing set Session("Recordset") = nothing NextRecordNumber = 1 ' Remove any leading and ending quotes from SearchString if not (SearchString = "") then SrchStrLen = len(SearchString) if left(SearchString, 1) = chr(34) then SrchStrLen = SrchStrLen-1 SearchString = right(SearchString, SrchStrLen) end if if right(SearchString, 1) = chr(34) then SrchStrLen = SrchStrLen-1 SearchString = left(SearchString, SrchStrLen) end if CompSearch = SearchString set Q = Server.CreateObject("ixsso.Query") set util = Server.CreateObject("ixsso.Util") ' Adding "@all" to query so that the meta keywords tag will get searched. Q.Query = "@all (" & CompSearch & ") " & QueryParameterString Q.SortBy = "rank[d]" Q.Columns = QueryColumns Q.MaxRecords = 100 Q.AllowEnumeration = True Q.Catalog = Catalog 'Now set up a search string, that searches for the words in the body of the text, not 'just the string of text (put AND between the words in the string). 'The logic: look for an occurence of a space, put everything since the last space 'into the TempString, then concatenate TempString and " and " onto the end of the 'search string (AndSearch). Continue this process until there are no more spaces 'or the end of the string is found. stringLen = 1 'get the position of the first space in the string MyPos = Instr(1, SearchString, chr(32), 0) do while (MyPos <> 0 or MyPos <> Null) 'get the next word in the string TempString = Mid(SearchString, stringLen, MyPos-stringLen) 'get the next word in the string (ahead by 2 - this is to check for booleans), but 'make sure that you have not hit the end of the string if not (Instr(MyPos + 1, SearchString, chr(32), 0) = 0) then CompString = Mid(SearchString, MyPos + 1, Instr(MyPos + 1, SearchString, chr(32), 0)-MyPos - 1) end if 'check for boolean values If StrComp(CompString, "and", 1)<>0 and StrComp(CompString, "not", 1)<>0 and StrComp(CompString, "or", 1)<>0 and StrComp(CompString, "near", 1)<>0 and StrComp(TempString, "and", 1)<>0 and StrComp(TempString, "not", 1)<>0 and StrComp(TempString, "or", 1)<>0 and StrComp(TempString, "near", 1)<>0 then AndSearch = AndSearch & TempString & " and " else AndSearch = AndSearch & TempString & " " end if stringLen = MyPos + 1 MyPos = Instr(stringLen, SearchString, chr(32), 0) TempString = "" Loop stringLen = stringLen TempString = Mid(SearchString, stringLen, len(SearchString)) AndSearch = AndSearch & TempString set Q_And = Server.CreateObject("ixsso.Query") Q_And.Query = AndSearch 'Do a query on the words of the string using AND Q_And.Query = "@all (" & AndSearch & ") " & QueryParameterString Q_And.SortBy = "rank[d]" Q_And.Columns = QueryColumns Q_And.MaxRecords = 100 Q_And.AllowEnumeration = True 'Now set up a search string, that searches for any of the words in the body of the text, 'not just the string of text (put OR between the words in the string). 'The logic: look for an occurence of a space, put everything since the last space 'into the TempString, then concatenate TempString and " or " onto the end of the 'search string (OrSearch). Continue this process until there are no more spaces 'or the end of the string is found. stringLen = 1 'get the position of the first space in the string MyPos = Instr(1, SearchString, chr(32), 0) do while (MyPos <> 0 or MyPos <> Null) 'get the next word in the string TempString = Mid(SearchString, stringLen, MyPos-stringLen) 'get the next word in the string (ahead by 2 - this is to check for booleans), but 'make sure that you have not hit the end of the string if not (Instr(MyPos + 1, SearchString, chr(32), 0) = 0) then CompString = Mid(SearchString, MyPos + 1, Instr(MyPos + 1, SearchString, chr(32), 0)-MyPos - 1) else CompString = " " end if 'check for boolean values If StrComp(CompString, "and", 1)<>0 and StrComp(CompString, "not", 1)<>0 and StrComp(CompString, "or", 1)<>0 and StrComp(CompString, "near", 1)<>0 and StrComp(TempString, "and", 1)<>0 and StrComp(TempString, "not", 1)<>0 and StrComp(TempString, "or", 1)<>0 and StrComp(TempString, "near", 1)<>0 then OrSearch = OrSearch & TempString & " or " else OrSearch = OrSearch & TempString & " " end if stringLen = MyPos + 1 MyPos = Instr(stringLen, SearchString, chr(32), 0) TempString = "" Loop TempString = Mid(SearchString, stringLen, len(SearchString)) OrSearch = OrSearch & TempString set Q_Or = Server.CreateObject("ixsso.Query") Q_Or.Query = OrSearch 'Do a query on the words of the string using AND Q_Or.Query = "@all (" & OrSearch & ") " & QueryParameterString Q_Or.SortBy = "rank[d]" Q_Or.Columns = QueryColumns Q_Or.MaxRecords = 100 Q_Or.AllowEnumeration = True if FormScope <> "/" then util.AddScopeToQuery Q, FormScope, "deep" end if if SiteLocale<>"" then Q.LocaleID = util.ISOToLocaleID(SiteLocale) end if 'if the user entered garbage this next line will catch it, this line also checks to determine 'which search to use (i.e. Regular, And or Or) Response.Write vbcrlf & "" & vbcrlf On Error Resume Next ' Defer error trapping. set RS = Q.CreateRecordSet("nonsequential") if RS.EOF then Response.Write vbcrlf & "" & vbcrlf On Error Resume Next ' Defer error trapping. set RS = Q_And.CreateRecordSet("nonsequential") if RS.EOF then Response.Write vbcrlf & "" & vbcrlf On Error Resume Next ' Defer error trapping. set RS = Q_Or.CreateRecordSet("nonsequential") end if end if if IsObject(RS) then ' RS is not an object when index server had a problem with the search criteria RS.PageSize = PageSize ActiveQuery = TRUE else ' The user put in a query we couldn't handle Response.Write "No documents matched the query." %> New search
<%
end if
else
Response.Write " " LastRecordOnPage = NextRecordNumber + RS.PageSize - 1 CurrentPage = RS.AbsolutePage if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then LastRecordOnPage = RS.RecordCount end if Response.Write "Documents " & NextRecordNumber & " to " & LastRecordOnPage if RS.RecordCount <> -1 then Response.Write " of " & RS.RecordCount end if Response.Write " matching the query " & chr(34) & "" Response.Write SearchString & "" & chr(34) & ". " Response.Write "
<%= NextRecordNumber%>. <%if VarType(RS("DocTitle")) = 1 or RS("DocTitle") = "" then%> "><%= Server.HTMLEncode( RS("filename") )%> <%else%> "><%= Server.HTMLEncode(RS("DocTitle"))%> <%end if%> <%if false and VarType(RS("characterization")) = 8 and RS("characterization") <> "" then%> Abstract:
<%= Server.HTMLEncode(RS("characterization"))%>
" else Response.Write "No more documents in the query "
end if
%> The query is too expensive to complete. The query took too long to complete.
|
Serving the communities of: Anmore, Belcarra, Coquitlam, New Westminster, Port
Coquitlam and Port Moody Developed with the assistance of Ionysys Technology Corporation |
||||