Søge script der søger i forskellige indexes
Jeg har et søge script (se koden nedenfor):---------- START --------------
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">
<title>Search</title>
<style>
<!--
a:link { text-decoration: none; color:#660066}
-->
</style>
</head>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"589\" class=\"scenetext\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" height=\"373\">
<tr>
<td width=\"589\" valign=\"top\" align=\"left\" height=\"25\"><form ACTION=\"Default.asp\" NAME=\"search\" METHOD=\"get\">
<p><input TYPE=\"TEXT\" NAME=\"SearchString\" SIZE=\"20\"><input TYPE=\"Submit\" VALUE=\"Search\" id=Submit1 name=Submit1><script language=\"javascript\"> document.search.SearchString.focus(); </script></form>
</td>
</tr>
<tr>
<html>
<body>
<td width=\"589\" height=\"348\">
<%
if request.querystring(\"searchstring\")<>\"\" then
\' *** Modifying the Form\'s background pattern.
\' If you want to use a different background color than white, simply edit the
\' bgcolor line below, replacing white with your color choice.
FormBG = \"bgcolor = \" & chr(34) & \"#FFFFFF\" & chr(34)
\' *** Modifying the Form\'s Search Scope.
\' The form will search from the root of your web server\'s namespace and below
\' (deep from \"/\" ). To search a subset of your server, for example, maybe just
\' a PressReleases directory, modify the scope variable below to list the virtual path to
\' search. The search will start at the directory you specify and include all sub-
\' directories.
FormScope = \"/\"
\' *** Modifying the Number of Returned Query Results.
\' You can set the number of query results returned on a single page
\' using the variable below.
PageSize = 10
\' *** Setting the Locale.
\' The following line sets the locale used for queries. In most cases, this
\' should match the locale of the server. You can set the locale below.
SiteLocale = \"da\"
\' ********** END QUICK CUSTOMIZATION SECTIONS ***********
noise=\",about,after,all,øl,sex,also,an,another,any,and,are,as,at,be,because,been,before,being,between,both,but,by,came,can,come,could,did,do,each,for,from,get,got,has,had,he,have,her,here,him,himself,his,how,if,in,into,is,it,like,make,many,me,might,more,most,much,must,my,never,near,now,of,on,only,or,other,our,out,over,said,same,see,should,since,some,still,such,take,than,that,the,their,them,then,there,these,they,this,those,through,to,too,under,up,very,was,way,we,well,were,what,where,which,while,who,with,would,you,your,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,$,1,2,3,4,5,6,7,8,9,0,_,!,&,~,|,?,I,\"
punc2=\"$,1234567890_!&~|? #+()\"
\'punc=\"$,1234567890_!&~|?#@%^+\"
punc=\"$,_!&~|?#@%^+\"
%>
<%
\' Set Initial Conditions
NewQuery = FALSE
UseSavedQuery = FALSE
SearchString = \"\"
\' Did the user press a SUBMIT button to execute the form? If so get the form variables.
if Request.ServerVariables(\"REQUEST_METHOD\") = \"POST\" then
SearchString = Request.Form(\"SearchString\")
SearchType=Request.QueryString(\"SearchType\")
if SearchString<>\"\" then
Session(\"SearchStringDisplay\")=SearchString
end if
FreeText = Request.Form(\"FreeText\")
QueryForm = \"Query.Asp\"
CiResultsSize = Request.Form(\"CiResultsSize\")
CiLimits = Request.Form(\"CiLimits\")
\' NOTE: this will be true only if the button is actually pushed.
\' if Request.Form(\"Action\") = \"Search\" then
NewQuery = TRUE
if CiLimits = \"on\" then
RankBase=50
else
RankBase=100
end if
\' end if
end if
if Request.ServerVariables(\"REQUEST_METHOD\") = \"GET\" then
SearchString = Request.QueryString(\"SearchString\")
QueryForm = \"Default.Asp\"
CiResultsSize = Request.QueryString(\"CiResultsSize\")
FreeText = Request.QueryString(\"FreeText\")
FormScope = Request.QueryString(\"sc\")
RankBase = Request.QueryString(\"RankBase\")
if Request.QueryString(\"pg\") <> \"\" then
NextPageNumber = Request.QueryString(\"pg\")
NewQuery = FALSE
UseSavedQuery = TRUE
else
NewQuery = SearchString <> \"\"
end if
end if
if NewQuery then
set Session(\"Query\") = nothing
set Session(\"Recordset\") = nothing
NextRecordNumber = 1
\'Strip punctuation from search term
for x = 1 to len(SearchString)
testpunc= mid(SearchString,x,1)
if instr(punc,testpunc) then
SearchStringErr= SearchStringErr
else
SearchStringErr = SearchStringErr + testpunc
end if
next
SearchString = SearchStringErr
if SearchType=0 Then
\'Strip noise words from search term
SearchStringComp=SearchString+\" \"
for x = 1 to len(SearchStringComp)
if mid(SearchStringComp,x,1)=\" \" Then
ncompare2 = \",\"+ncompare+\",\"
if instr(noise,ncompare2) = 0 then
NewCompare=NewCompare+\" \"+ncompare
End If
ncompare=\"\"
else
ncompare=ncompare+mid(SearchString,x,1)
end if
next
x = len(NewCompare)
if left(NewCompare,1) = \" \" Then
NewCompare = right(NewCompare,(x-1))
end if
SearchString=NewCompare
CompSearch = \"$CONTENTS \" + SearchString
end if
if SearchType=1 Then
CompSearch = chr(34) + SearchString + chr(34)
end if
if SearchType=2 Then
\'Strip noise words from search term
SearchStringComp=SearchString+\" \"
for x = 1 to len(SearchStringComp)
if mid(SearchStringComp,x,1)=\" \" Then
ncompare2 = \",\"+ncompare+\",\"
if instr(noise,ncompare2) = 0 then
NewCompare=NewCompare+\" \"+ncompare
End If
ncompare=\"\"
else
ncompare=ncompare+mid(SearchString,x,1)
end if
next
x = len(NewCompare)
if left(NewCompare,1) = \" \" Then
NewCompare = right(NewCompare,(x-1))
end if
SearchString=NewCompare
slen=len(SearchString)
for k = 1 to slen
slet = Mid(SearchString,k,1)
if slet <> \" \" then
ss1=ss1+slet
else
ss1=ss1+ \" AND \"
end if
Next
CompSearch=ss1
If Right(CompSearch,5) = \" AND \" Then CompSearch = Left(CompSearch,Len(CompSearch)-5)
end if
if SearchType=3 Then
\'Strip noise words from search term
SearchStringComp=SearchString+\" \"
for x = 1 to len(SearchStringComp)
if mid(SearchStringComp,x,1)=\" \" Then
ncompare2 = \",\"+ncompare+\",\"
if instr(noise,ncompare2) = 0 then
NewCompare=NewCompare+\" \"+ncompare
End If
ncompare=\"\"
else
ncompare=ncompare+mid(SearchString,x,1)
end if
next
x = len(NewCompare)
if left(NewCompare,1) = \" \" Then
NewCompare = right(NewCompare,(x-1))
end if
SearchString=NewCompare
slen=len(SearchString)
for k = 1 to slen
slet = Mid(SearchString,k,1)
if slet <> \" \" then
ss1=ss1+slet
else
ss1=ss1+ \" OR \"
end if
Next
CompSearch=ss1
If Right(CompSearch,4) = \" OR \" Then CompSearch = Left(CompSearch,Len(CompSearch)-4)
end if
if SearchType=4 Then
\'Strip noise words from search term
NCompare=\"\"
NewCompare=\"\"
SearchStringComp=SearchString+\" \"
for x = 1 to len(SearchStringComp)
if mid(SearchStringComp,x,1)=\" \" Then
ncompare2 = \",\"+ncompare+\",\"
if instr(noise,ncompare2) = 0 then
NewCompare=NewCompare+\" \"+ncompare
End If
ncompare=\"\"
else
ncompare=ncompare+mid(SearchString,x,1)
end if
next
x = len(NewCompare)
if left(NewCompare,1) = \" \" Then
NewCompare = right(NewCompare,(x-1))
end if
SearchString=NewCompare
CompSearch = SearchString
end if
set Q = Server.CreateObject(\"ixsso.Query\")
set util = Server.CreateObject(\"ixsso.Util\")
Q.Query = CompSearch & \" and not #vpath *\\temp* and not #vpath *\\ctotest* and not #vpath *\\cto* and not #vpath *\\easycareadmin* and not #vpath *\\images* and not #vpath *\\backup* and not #vpath *\\xxadmin* and not #vpath *\\kickoffcompaq* and not #vpath *\\stats* and not #vpath *\\published_xml* and not #vpath *\\_* and not #vpath *\\admin* and not #vpath *\\Nyhedsbrev*\"
Q.Catalog = \"Web\"
Q.SortBy = \"rank[d]\"
Q.Columns = \"DocTitle, vpath, filename, size, write, characterization, rank\"
Q.MaxRecords = RankBase
if FormScope <> \"/\" then
\'util.AddScopeToQuery Q, FormScope, \"deep\"
end if
if SiteLocale<>\"\" then
Q.LocaleID = util.ISOToLocaleID(SiteLocale)
end if
On Error Resume Next
set RS = Q.CreateRecordSet(\"nonsequential\")
RS.PageSize = PageSize
Test = RS.PageSize
ActiveQuery = TRUE
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
RS.AbsolutePage = NextPageNumber
NextRecordNumber = RS.AbsolutePosition
end if
ActiveQuery = TRUE
else
Response.Write \"Fejl - ingen gemt forespørgsel\"
end if
end if
If Err<>424 Then
if ActiveQuery then
if not RS.EOF then
%>
<%LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
KLastRecordOnPage=LastRecordOnPage
If KLastRecordOnPage>RS.RecordCount Then KLastRecordOnPage=RS.RecordCount%>
<b>Du søgte efter :<i> <%=request.querystring(\"SearchString\")%></i></b><br><br>
<font face=\"Verdana\" size=\"1\" color=\"#999999\"><i>
<b><%=NextRecordNumber%> - <%=KLastRecordOnPage%> af <%=RS.RecordCount%> resultater fundet</b></i></font><br>
<p>
<%
hits=RS.RecordCount
LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
CurrentPage = RS.AbsolutePage
if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then
LastRecordOnPage = RS.RecordCount
end if
%>
<% if Not RS.EOF and NextRecordNumber <= LastRecordOnPage then%>
<table border=\"0\">
<% end if %>
<%
Do While Not RS.EOF and NextRecordNumber <= LastRecordOnPage
\' This is the detail portion for Title, Description, URL, Size, and
\' Modification Date.
TmpExt = Server.HTMLEncode( RS(\"filename\") )
FullExt = Right(TmpExt, 3)
If FullExt <> \"cnt\" and FullExt <> \"hhc\" and FullExt <> \"hpj\" and FullExt <> \"hlp\" and FullExt <> \"rtf\" and FullExt <> \"asf\" and FullExt <> \"gid\" and FullExt <> \"fts\" and FullExt <> \"wmp\" and FullExt <> \"hhk\" and FullExt <> \"txt\" and FullExt <> \"ass\" and FullExt <> \"idq\" and FullExt <> \"ncr\" and FullExt <> \"ncl\" and FullExt <> \"url\" and FullExt <> \"css\" and FullExt <> \"prp\" and FullExt <> \"htx\" and FullExt <> \"htw\" and FullExt <> \"tmp\" and FullExt <> \"mdb\" and FullExt <> \"xls\" and FullExt <> \"chm\" Then
\' If there is a title, display it, otherwise display the filename.
%>
<p>
<tr class=\"RecordTitle\">
<td><font face=\"Verdana\" size=\"1\" color=\"#999999\"><b><%=NextRecordNumber%>.</b></td>
<b class=\"RecordTitle\"> <td><b>
<%if VarType(RS(\"DocTitle\")) = 1 or RS(\"DocTitle\") = \"\" then%>
<font face=\"Verdana\" size=\"1\" color=\"#999999\">
<a href=\"<%=RS(\"vpath\")%>\" class=\"RecordTitle\"><%= Server.HTMLEncode( RS(\"filename\") )%></a> (<%=RS(\"rank\")/10%>%)
<%else%>
<a href=\"<%=RS(\"vpath\")%>\" class=\"RecordTitle\"><%= Server.HTMLEncode(RS(\"DocTitle\"))%></a> (<%=RS(\"rank\")/10%>%)
<%end if%> </font>
</b>
<font face=\"Verdana\" size=\"1\" color=\"#999999\">
</b><br>
<%if VarType(RS(\"characterization\")) = 8 and RS(\"characterization\") <> \"\" then%>
<%= RS(\"characterization\")%>
<%end if%>
<%if CiResultsSize = \"on\" then%>
<%end if%>
</td>
</tr>
<%
else
NextRecordNumber = NextRecordNumber-1
end if%>
<%
RS.MoveNext
NextRecordNumber = NextRecordNumber+1
Loop
%>
</table>
<p>
<%end if%>
<table>
<%
\' This is the \"previous\" button.
\' This retrieves the previous page of documents for the query.
%>
<%SaveQuery = FALSE%>
<%if CurrentPage > 1 and RS.RecordCount <> -1 then %>
<td align=\"left\">
<form action=\"<%=QueryForm%>\" method=\"get\" id=\"tilbage\">
<input TYPE=\"HIDDEN\" NAME=\"SearchString\" VALUE=\"<%=SearchString%>\">
<input TYPE=\"HIDDEN\" NAME=\"FreeText\" VALUE=\"<%=FreeText%>\">
<input TYPE=\"HIDDEN\" NAME=\"CiResultsSize\" VALUE=\"<%=CiResultsSize%>\">
<input TYPE=\"HIDDEN\" NAME=\"sc\" VALUE=\"<%=FormScope%>\">
<input TYPE=\"HIDDEN\" name=\"pg\" VALUE=\"<%=CurrentPage-1%>\">
<input TYPE=\"HIDDEN\" NAME=\"RankBase\" VALUE=\"<%=RankBase%>\">
<p>
<font face=\"Verdana\" size=\"2\" color=\"#999999\">
<a href=\"java script: tilbage.submit();\" style=\"text-decoration: none; color: #660066\">
<< Tilbage</a></font><font face=\"Verdana\" size=\"1\" color=\"#999999\">
</font>
</p>
</form>
</td>
<%SaveQuery = TRUE%>
<%end if
\' This is the \"next\" button for unsorted queries.
\' This retrieves the next page of documents for the query.
if Not RS.EOF then%>
<td align=\"right\">
<form action=\"<%=QueryForm%>\" method=\"get\" id=\"frem\">
<input TYPE=\"HIDDEN\" NAME=\"SearchString\" VALUE=\"<%=SearchString%>\">
<input TYPE=\"HIDDEN\" NAME=\"FreeText\" VALUE=\"<%=FreeText%>\">
<input TYPE=\"HIDDEN\" NAME=\"CiResultsSize\" VALUE=\"<%=CiResultsSize%>\">
<input TYPE=\"HIDDEN\" NAME=\"sc\" VALUE=\"<%=FormScope%>\">
<input TYPE=\"HIDDEN\" name=\"pg\" VALUE=\"<%=CurrentPage+1%>\">
<input TYPE=\"HIDDEN\" NAME=\"RankBase\" VALUE=\"<%=RankBase%>\">
<p>
<font face=\"Verdana\" size=\"2\" color=\"#999999\">
<a href=\"java script:frem.submit();\" style=\"text-decoration: none; color: #660066\">Frem
>></a></font><font face=\"Verdana\" size=\"1\" color=\"#999999\">
</font>
</p>
</form>
</td>
<%SaveQuery = TRUE%>
<%end if%>
</table>
<% \' Display the page number %>
<%if RS.RecordCount = 0 then%>
<p>No documents where found for: <%=SearchString%>.<br><br>
You can: </p>
<ul>
<li>Search related subjects.
<li>Check your spelling.
<li>Try another search method (Standard, exact, word choice, all word or Boolean can be used).
</ul>
<%else%>
<p>Page <%=CurrentPage%>
<%if RS.PageCount <> -1 then
Response.Write \" of \" & RS.PageCount
end if
end if
\' 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
end if %>
</body>
</html>
<%
else
\'Strip noise words from search term
NCompare=\"\"
NewCompare=\"\"
SearchStringComp=SearchString+\" \"
for x = 1 to len(SearchStringComp)
if mid(SearchStringComp,x,1)=\" \" Then
ncompare2 = \",\"+ncompare+\",\"
if instr(noise,ncompare2) = 0 then
NewCompare=NewCompare+\" \"+ncompare
End If
ncompare=\"\"
else
ncompare=ncompare+mid(SearchString,x,1)
end if
next
x = len(NewCompare)
if left(NewCompare,1) = \" \" Then
NewCompare = right(NewCompare,(x-1))
end if
SearchString=NewCompare
\'Strip punctuation from search term
SearchStringErr = \"\"
for x = 1 to len(SearchString)
testpunc= mid(SearchString,x,1)
if instr(punc2,testpunc) then
SearchStringErr= SearchStringErr
else
SearchStringErr = SearchStringErr + testpunc
end if
next
SearchString = SearchStringErr
CompSearch=SearchString
if SearchString = \"\" or instr(SearchString,\"*\") or instr(CompSearch,\")\") or instr(CompSearch,\"(\") or right(CompSearch,3)=\"OR \" or right(CompSearch,4)=\"AND \" then%>
<b>Your search didn\'t complete!.</b><%
end if
end if
end if
%></td>
</tr>
</table>
</span></p>
<p valign=\"middle\" align=\"left\" colspan=\"2\" style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px; MARGIN-LEFT: 2px; LINE-HEIGHT: 100%\">
<center>
<p></p>
</center>
------------- SLUT -------------
Jeg vil gerne have en/flere check boxe hvor der f.eks. skal stå: IndexA, IndexB osv. og hvis man så klikker denne af før man klikker Search skal den søge i IndexA, IndexB osv.
