Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search engines done in ASP

Status
Not open for further replies.

dhere38

Programmer
Sep 12, 2000
20
US
trying to develope a search engine with "ASP" for a site in order to search Quark files. This is my first attempt can anybody help? Thank you
 
<!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML 3.0//EN&quot; &quot;html.dtd&quot;>
<HTML>
<HEAD>

<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;Server&quot;>
<!--
option explicit
-->
</SCRIPT>

<TITLE>Index Server Search Form</TITLE>

<META NAME=&quot;DESCRIPTION&quot; CONTENT=&quot; ASP query form for
Microsoft Index Server&quot;>
<META NAME=&quot;KEYWORDS&quot; CONTENT=&quot;query, content, hit, asp&quot;>
<META NAME=&quot;MS.LOCALE&quot; CONTENT=&quot;EN-US&quot;>
<META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html;
charset=Windows-1252&quot;>

<%
NewQuery = FALSE
UseSavedQuery = FALSE
QueryForm = Request.ServerVariables( &quot;PATH_INFO&quot; )
SearchString = &quot;&quot;
if Request.ServerVariables(&quot;REQUEST_METHOD&quot;) = &quot;POST&quot; then
SearchString = Request.Form(&quot;SearchString&quot;)
pg = Request.Form(&quot;pg&quot;)

if pg <> &quot;&quot; then
NextPageNumber = pg
NewQuery = FALSE
UseSavedQuery = TRUE
else
NewQuery = SearchString <> &quot;&quot;
end if
end if

%>
</HEAD>
<p>

<TABLE width=&quot;657&quot;>
<TR bgcolor=&quot;#336699&quot; bordercolor=&quot;#333333&quot;>
<TD ALIGN=LEFT width=&quot;649&quot; height=&quot;31&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;-1&quot;><b><font color=&quot;#FFFFFF&quot;>Search
for: </font></b></font></TD>
</TR>
<TR bgcolor=&quot;#336699&quot; bordercolor=&quot;#333333&quot;>
<TD width=&quot;649&quot; height=&quot;8&quot;>
<FORM ACTION='<%= QueryForm%>' METHOD=POST>
<TABLE width=&quot;664&quot;>
<TR>
<TD width=&quot;310&quot;>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;SearchString&quot; SIZE=&quot;50&quot;
MAXLENGTH=&quot;100&quot; VALUE='<%=SearchString%>'>
</TD>
<TD width=&quot;170&quot;> <select name=&quot;listdown&quot; size=&quot;1&quot;>
<option value=&quot;1&quot;>Entire Site</option>
<option value=&quot;2&quot;>Home</option>
<option value=&quot;3&quot;>Announcement</option>
<option value=&quot;4&quot;>Bussiness</option>
<option value=&quot;5&quot;>Realtime</option>
<option value=&quot;6&quot;>Talk</option>
<option value=&quot;7&quot;>News</option>
<option value=&quot;8&quot;>Join</option>
<option value=&quot;9&quot;>Members</option>
<option value=&quot;10&quot;>Help</option>
</select>

</TD>
<TD width=&quot;168&quot;>
<%
if SearchString <> &quot;&quot; then
if NewQuery then
set Session(&quot;Query&quot;) = nothing
set Session(&quot;Recordset&quot;) = nothing
NextRecordNumber = 1

Dim Q

set Q = Server.CreateObject(&quot;ixsso.Query&quot;)
set util = Server.CreateObject(&quot;ixsso.util&quot;)
Q.SetQueryFromURL(Request.QueryString)
Q.Query = SearchString
Q.SortBy = &quot;rank[d]&quot;
Q.Columns = &quot;DocTitle, vpath, path, filename, size, write, characterization&quot;

if request(&quot;listdown&quot;) = &quot;1&quot; then
util.AddScopeToQuery Q,&quot;D:\inetpub\
elseif request(&quot;listdown&quot;) = &quot;2&quot; then
util.AddScopeToQuery Q,&quot;D:\inetpub\
elseif request(&quot;listdown&quot;) = &quot;3&quot; then
util.AddScopeToQuery Q,&quot;D:\inetpub\
elseif request(&quot;listdown&quot;) = &quot;4&quot; then
util.AddScopeToQuery Q,&quot;D:\inetpub\
elseif request(&quot;listdown&quot;) = &quot;5&quot; then
util.AddScopeToQuery Q,&quot;D:\inetpub\
elseif request(&quot;listdown&quot;) = &quot;6&quot; then
util.AddScopeToQuery Q,&quot;D:\inetpub\
elseif request(&quot;listdown&quot;) = &quot;7&quot; then
util.AddScopeToQuery Q,&quot;D:\inetpub\
elseif request(&quot;listdown&quot;) = &quot;8&quot; then
util.AddScopeToQuery Q,&quot;D:\inetpub\
elseif request(&quot;listdown&quot;) = &quot;9&quot; then
util.AddScopeToQuery Q,&quot;D:\inetpub\
else set Q = Server.CreateObject(&quot;ixsso.Query&quot;)
util.AddScopeToQuery Q,&quot;D:\inetpub\
end if

set RS = Q.CreateRecordSet(&quot;nonsequential&quot;)

RS.PageSize = 10
ActiveQuery = TRUE

elseif UseSavedQuery then
if IsObject( Session(&quot;Query&quot;) ) And IsObject( Session(&quot;RecordSet&quot;) ) then
set Q = Session(&quot;Query&quot;)
set RS = Session(&quot;RecordSet&quot;)

if RS.RecordCount <> -1 and NextPageNumber <> -1 then
RS.AbsolutePage = NextPageNumber
NextRecordNumber = RS.AbsolutePosition
end if

ActiveQuery = TRUE
else
Response.Write &quot;ERROR - No saved query&quot;
end if
end if
%>
<input type=&quot;SUBMIT&quot; name=&quot;Submit&quot; value=&quot;Search&quot;>
</TABLE>
</FORM>
</TD>
</TR>
</TABLE>

<%
if ActiveQuery then
if not RS.EOF then
%>
<p>
<p>

<%
LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
CurrentPage = RS.AbsolutePage
if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then
LastRecordOnPage = RS.RecordCount
end if

Response.Write &quot;Documents &quot; & NextRecordNumber & &quot; to &quot; & LastRecordOnPage
if RS.RecordCount <> -1 then
Response.Write &quot; of &quot; & RS.RecordCount
end if
Response.Write &quot; matching the query &quot; & chr(34) & &quot;<I>&quot;
Response.Write SearchString & &quot;</I>&quot; & chr(34) & &quot;<P>&quot;
%>
<dl>

<!-- BEGIN first row of query results table -->
<% Do While Not RS.EOF and NextRecordNumber <= LastRecordOnPage %>

<%
' This is the detail portion for Title, Abstract, URL, Size, and
' Modification Date.
' If there is a title, display it, otherwise display the virtual path.
%>
<p>
<dt><%= NextRecordNumber%>
<%if VarType(RS(&quot;DocTitle&quot;)) = 1 or RS(&quot;DocTitle&quot;) = &quot;&quot; then%>
<b><a href=&quot;<%=RS(&quot;vpath&quot;)%>&quot;><%= Server.HTMLEncode( RS(&quot;filename&quot;) )%></a></b>
<%else%>
<b><a href=&quot;<%=RS(&quot;vpath&quot;)%>&quot;><%= Server.HTMLEncode(RS(&quot;DocTitle&quot;))%></a></b>
<%end if%>
<dd>
<%if VarType(RS(&quot;characterization&quot;)) = 8 and RS(&quot;characterization&quot;) <> &quot;&quot; then%>
<b><i>Abstract: </I></b><%= Server.HTMLEncode(RS(&quot;characterization&quot;))%>
<br>
<%end if%>
<cite>
<a href=&quot;<%=RS(&quot;vpath&quot;)%>&quot;> <font size=-1> - <%if RS(&quot;size&quot;) = &quot;&quot; then%>(size and time unknown)<%else%>size <%=RS(&quot;size&quot;)%> bytes - <%=RS(&quot;write&quot;)%> GMT<%end if%></font>
</cite>

<%
RS.MoveNext
NextRecordNumber = NextRecordNumber+1
Loop
%>

</dl>


<P><BR>

<%
else ' NOT RS.EOF
if NextRecordNumber = 1 then
Response.Write &quot;No documents matched the query<P>&quot;
else
Response.Write &quot;No more documents in the query<P>&quot;
end if

end if ' NOT RS.EOF
%>


<!--
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
-->

<%if Q.QueryIncomplete then%>
<P>
<I><B>The query is too expensive to complete.</B></I><BR>
<%end if%>

<!--
If the query took too long to execute (for example, if too much work
was required to resolve the query), let the user know
-->

<%if Q.QueryTimedOut then%>
<P>
<I><B>The query took too long to complete.</B></I><BR>
<%end if%>


<TABLE>

<!--
This is the &quot;previous&quot; 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=&quot;<%= QueryForm%>&quot; method=&quot;POST&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;SearchString&quot; VALUE=&quot;<%=SearchString%>&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; name=&quot;pg&quot; VALUE=&quot;<%=CurrentPage-1%>&quot; >
<input type=&quot;submit&quot; value=&quot;Previous <%=RS.PageSize%> documents&quot;>
</form>

</td>
<%SaveQuery = TRUE%>
<%end if%>

<!--
This is the &quot;next&quot; button.
This button retrieves the next page of documents for the query.
If the RS.RecordCount is available, the number of
documents on the next page will be displayed.
-->

<%if Not RS.EOF then%>
<td align=right>
<form action=&quot;<%= QueryForm%>&quot; method=&quot;POST&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;SearchString&quot; VALUE=&quot;<%=SearchString%>&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; name=&quot;pg&quot; VALUE=&quot;<%=CurrentPage+1%>&quot; >

<% NextString = &quot;Next &quot;
if RS.RecordCount <> -1 then
NextSet = (RS.RecordCount - NextRecordNumber) + 1
if NextSet > RS.PageSize then
NextSet = RS.PageSize
end if
NextString = NextString & NextSet & &quot; documents&quot;
else
NextString = NextString & &quot; page of documents&quot;
end if
%>
<input type=&quot;submit&quot; value=&quot;<%=NextString%>&quot;>
</form>
</td>
<%SaveQuery = TRUE%>
<%end if%>

</TABLE>


<!-- Display the page number -->

Page <%=CurrentPage%>
<%if RS.PageCount <> -1 then
Response.Write &quot; of &quot; & RS.PageCount
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(&quot;Query&quot;) = Q
set Session(&quot;RecordSet&quot;) = RS
else
RS.close
Set RS = Nothing
Set Q = Nothing
set Session(&quot;Query&quot;) = Nothing
set Session(&quot;RecordSet&quot;) = Nothing
end if
%>

<% end if
elseif not NewQuery then
Response.Write &quot;&quot;
else
Response.Write &quot;Please enter a word or phrase to search for.&quot;
end if

%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top