<%
'Response.Expires = 0
msg="Results:"
keyword = trim(Request.Form("keyword"))
page = Request.Form("page")
catalog = Application("SearchCatalog")
catalog = "UI2"
if catalog = "" then
catalog = "UI"
end if
FormScope = Application("SearchScope")
msg=msg&"IntheBeginning: keyword="&keyword&" "
PageSize = Application("SearchPageSize")
if PageSize = "" then
PageSize = 10
end if
if Request("sp-c") <> "" then
PageSize = Request("sp-c")
end if
maxRecords = Application("SearchMaxRecords")
if maxRecords = "" then
maxRecords = 200
end if
SiteLocale = "EN-US"
NewQuery = FALSE
UseSavedQuery = FALSE
QueryForm = Request.ServerVariables("PATH_INFO")
xml = "" & vbcrlf
if Request.ServerVariables("REQUEST_METHOD") = "POST" then
msg=msg&"POST "
NewQuery = TRUE
RankBase=1000
else
keyword = trim(Request.QueryString("keyword"))
RankBase = Request.QueryString("RankBase")
if Request.QueryString("pg") <> "" then
NextPageNumber = Request.QueryString("pg")
NewQuery = FALSE
UseSavedQuery = TRUE
else
NewQuery = keyword <> ""
end if
end if
if NewQuery and keyword <> "" then
msg=msg&"starting over...keyword="&keyword&" "
set Session("Query") = nothing
set Session("Recordset") = nothing
NextRecordNumber = 1
' Remove any leading and ending quotes from SearchString
SrchStrLen = len(keyword)
if left(keyword, 1) = chr(34) then
SrchStrLen = SrchStrLen-1
keyword = right(keyword, SrchStrLen)
end if
if right(keyword, 1) = chr(34) then
SrchStrLen = SrchStrLen-1
keyword = left(keyword, SrchStrLen)
end if
CompSearch = ""
if Request("sp-w") <> "" then
arrKeywords = split(keyword," ")
keyword = ""
for p = 0 to ubound(arrKeywords)
if trim(arrKeywords(p)) <> "" then
keyword = keyword & arrKeywords(p) & "** "
end if
next
end if
if Request("sp-p") = "" or Request("sp-p") = "any" then
CompSearch = keyword
elseif Request("sp-p") = "phrase" then
CompSearch = "{phrase}"&keyword&"{/phrase}"
elseif Request("sp-p") = "all" then
arrKeywords = split(keyword," ")
kwAnd = " "
for p = 0 to ubound(arrKeywords)
if trim(arrKeywords(p)) <> "" then
CompSearch = CompSearch & kwAnd & arrKeywords(p)
kwAnd = " and "
end if
next
end if
DateSearch = ""
if Request("sp-d") = "custom" then
if Request("sp-date-range") <> "-1" then
DateSearch = "& @Write > -" & Request("sp-date-range") & "d"
end if
else ''specific date
if (Request("sp-start-year") <> "" and Request("sp-start-month") <> "" and Request("sp-start-day") <> "") then
DateSearch = DateSearch & " & @Write > " & Request("sp-start-year") & "-" & Request("sp-start-month") & "-" & Request("sp-start-day")
end if
if (Request("sp-end-year") <> "" and Request("sp-end-month") <> "" and Request("sp-end-day") <> "") then
DateSearch = DateSearch & " & @Write <= " & Request("sp-end-year") & "-" & Request("sp-end-month") & "-" & Request("sp-end-day")
end if
end if
msg=msg+"CompSearch:" & CompSearch & " DateSearch: " & DateSearch &" "
set Q = Server.CreateObject("ixsso.Query")
set util = Server.CreateObject("ixsso.Util")
if catalog <> "" then
Q.Catalog = catalog
end if
Q.Query = CompSearch & DateSearch
if request("sp-s") = "1" then
msg=msg&"sorting by date "
Q.SortBy = "write[d]"
else
msg=msg&"sorting by rank "
Q.SortBy = "rank[d]"
end if
if request("sp-m") = "0" then
Q.Columns = "DocTitle, path, filename, size, write, rank, characterization, Directory, htmlheading1, htmlhref, shortfilename"
' Q.Columns = "DocTitle, vpath, filename, size, write, rank"
else
Q.Columns = "DocTitle, path, filename, size, write, rank, characterization, Directory"
end if
Q.MaxRecords = maxRecords
Q.LocaleID = util.ISOToLocaleID(SiteLocale)
if FormScope <> "" then
util.AddScopeToQuery Q, FormScope, "deep"
end if
%>
<%
on error resume next
set RS = Q.CreateRecordSet("nonsequential")
if err.number <>0 then
%>
  <%=err.description%>
<%
end if
b= rs.fields.count
if err.number <> 0 then
xml = xml & "" & err.description & ""
set RS = nothing
else
RS.PageSize = PageSize
ActiveQuery = TRUE
end if
err.clear
elseif UseSavedQuery then
if IsObject( Session("Query") ) And IsObject( Session("RecordSet") ) then
set Q = Session("Query")
set RS = Session("RecordSet")
if RS.RecordCount <> -1 and NextPageNumber <> -1 then
if int(nextpagenumber) > int(rs.pagecount) then
nextpagenumber = rs.pagecount
elseif int(nextpagenumber) < 1 then
nextpagenumber = 1
end if
RS.AbsolutePage = NextPageNumber
NextRecordNumber = RS.AbsolutePosition
end if
ActiveQuery = TRUE
else
errMsg = "ERROR - No saved query"
end if
end if
if ActiveQuery then
if not RS.EOF then
if trim(keyword) <> "" then xml = xml & "" & vbcrlf
LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
CurrentPage = RS.AbsolutePage
if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then
LastRecordOnPage = RS.RecordCount
end if
xml = xml & "" & NextRecordNumber & "" & vbcrlf
xml = xml & "" & LastRecordOnPage & "" & vbcrlf
xml = xml & "" & RS.recordcount & "" & vbcrlf
xml = xml & "" & keyword & "" & vbcrlf
headMsg = "Documents " + cstr(NextRecordNumber) + " through " + cstr(LastRecordOnPage) + " of " + cstr(RS.recordcount) + " matching the query " + """" + keyword + """" %>
<%=headMsg%>
<% Do While Not RS.EOF and NextRecordNumber <= LastRecordOnPage
xml = xml & "" & vbcrlf
xml = xml & "" & NextRecordNumber & "" & vbcrlf
xml = xml & "" & Request("server_name") & "" & vbcrlf
for i = 0 to rs.fields.count - 1
xml = xml & "<" & ucase(rs(i).name) & ">" & vbcrlf & _
"" & vbcrlf & _
"" & ucase(rs(i).name) & ">" & vbcrlf
next
if NextRecordNumber = 1 then
RankBase=RS("rank")
end if
if RankBase>1000 then
RankBase=1000
elseif RankBase<1 then
RankBase=1
end if
NormRank = int(5 * RS("rank")/RankBase)
if NormRank < 1 then NormRank = 1 end if
xml = xml & "" & normrank & "" & vbcrlf
xml = xml & "" & vbcrlf
%>
<%
RS.MoveNext
NextRecordNumber = NextRecordNumber + 1
Loop
else ' RS.EOF
if NextRecordNumber = 1 then
headMsg = "Sorry, no match found. Please try your search again with different criteria, or use the Advanced Search."
%>
<%
xml = xml & "Advanced Search.]]>" & vbcrlf & _
"" & vbcrlf
else
xml = xml & "No more documents in the query" & vbcrlf & _
"" & vbcrlf
%>
<%=headMsg%>
<%
end if
end if ' RS.EOF
if Q.QueryIncomplete then
' If the query was not executed because it needed to enumerate to
' resolve the query instead of using the index, but AllowEnumeration
' was FALSE, let the user know
xml = xml & "The query is too expensive to complete."
end if
if Q.QueryTimedOut then
' If the query took too long to execute (for example, if too much work
' was required to resolve the query), let the user know
xml = xml & "The query took too long to complete."
end if
SaveQuery = FALSE
' This is the "previous" button.
' This retrieves the previous page of documents for the query.
if CurrentPage > 1 and RS.RecordCount <> -1 then
xml = xml & "" & vbcrlf & _
"" & vbcrlf & _
"" & (currentPage - 1) & "" & vbcrlf & _
"" & vbcrlf
SaveQuery = TRUE
end if
' This loop adds a link for each page of results
for i = 1 to RS.pagecount
xml = xml & "" & vbcrlf & _
"" & i & "" & vbcrlf & _
"" & i & "" & vbcrlf
if i = currentPage then xml = xml & "" & vbcrlf
xml = xml & "" & vbcrlf
next
a = rs.RecordCount
' This is the "next" button for unsorted queries.
' This retrieves the next page of documents for the query.
if Not RS.EOF then
xml = xml & "" & vbcrlf & _
">]]]>" & vbcrlf & _
"" & (currentPage + 1) & "" & vbcrlf & _
"" & vbcrlf
SaveQuery = TRUE
end if
' Display the page number
xml = xml & "" & currentPage & "" & vbcrlf & _
"" & RS.pagecount & "" & vbcrlf & _
"" & rankbase & "" & vbcrlf
'if RS.PageCount <> -1 then
' If either of the previous or back buttons were displayed, save the query
' and the recordset in session variables.
if SaveQuery then
set Session("Query") = Q
set Session("RecordSet") = RS
else
'RS.close
'Set RS = Nothing
Set Q = Nothing
'set Session("Query") = Nothing
'set Session("RecordSet") = Nothing
end if
%>
<%if RS.pagecount >= 1 then %> Result Pages: <% end if%>
<% if currentPage > 1 then %>
>
<< Previous
<% end if%>
<%
for i = 1 to RS.pagecount
if i = currentPage then %>
<%=i%>
<%else%>
>
<%=i%>
<%end if
next%>
<% if currentPage < RS.pagecount then %>
>
Next >>
<% end if%>