home *** CD-ROM | disk | FTP | other *** search
- <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
- <HTML>
- <HEAD>
- <SCRIPT LANGUAGE="VBScript" RUNAT="Server">
- <!--#INCLUDE FILE="adovbs.inc"-->
-
- </SCRIPT>
- <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#000066" VLINK="#808080" ALINK="#FF0000" TOPMARGIN=0 >
- <TITLE>Advanced Index Server Search Form</TITLE>
- <META NAME="DESCRIPTION" CONTENT="Sample SQL query form for Microsoft Index Server">
- <META NAME="AUTHOR" CONTENT="OLE DB Provider for Index Server Team">
- <META NAME="KEYWORDS" CONTENT="sql, query, content, hit">
- <META NAME="SUBJECT" CONTENT="sample form">
- <META NAME="MS.CATEGORY" CONTENT="Internet">
- <META NAME="MS.LOCALE" CONTENT="EN-US">
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
- <%
- Const STAT_BUSY = 0
- Const STAT_ERROR = &H1
- Const STAT_DONE = &H2
- Const STAT_REFRESH = &H3
- Const STAT_PARTIAL_SCOPE = &H8
- Const STAT_NOISE_WORDS = &H10
- Const STAT_CONTENT_OUT_OF_DATE = &H20
- Const STAT_REFRESH_INCOMPLETE = &H40
- Const STAT_CONTENT_QUERY_INCOMPLETE = &H80
- Const STAT_TIME_LIMIT_EXCEEDED = &H100
-
- Function GetCiOutOfDate(value)
- GetCiOutOfDate = value And STAT_CONTENT_OUT_OF_DATE
- end Function
-
- Function GetCiQueryIncomplete(value)
- GetCiQueryIncomplete = value And STAT_CONTENT_QUERY_INCOMPLETE
- end Function
-
- Function GetCiQueryTimedOut(value)
- GetCiQueryTimedOut = value And STAT_TIME_LIMIT_EXCEEDED
- end Function
-
- DebugFlag = FALSE
- NewQuery = FALSE
- SearchString = ""
- CiMaxRecords = 10
- if Request.ServerVariables("REQUEST_METHOD") = "POST" then
- SearchString = Request.Form("SearchString")
- DocAuthorRestriction = Request.Form("DocAuthorRestriction")
- FSRest = Request.Form("FSRest")
- FSRestVal = Request.Form("FSRestVal")
- FSRestOther = Request.Form("FSRestOther")
- FMMod = Request.Form("FMMod")
- FMModDate = Request.Form("FMModDate")
- SortBy = Request.Form("SortBy")
- Colset = Request.Form("ColChoice")
- CiMaxRecords = Request.Form("CiMaxRecords")
- NewQuery = TRUE
- End if
- %>
- </HEAD>
-
- <TABLE>
- <TR><TD><A HREF="http://www.microsoft.com/ntserver/search" style="text-decoration: none" target="_top"><IMG SRC ="is2logo.gif" VALIGN=MIDDLE ALIGN=LEFT></a></TD></TR>
- <TR><TD ALIGN="RIGHT"><H3>Advanced SQL Sample</H3></TD></TR>
- </TABLE>
-
-
- <SCRIPT LANGUAGE=JavaScript>
- <!--
- function SetAll()
- {
- document.QForm.SearchString.value = "<%=SearchString%>";
- document.QForm.CiMaxRecords.Value = <%=CiMaxRecords%>;
-
- <%select case FSRest%>
- <%case " > "%>
- document.QForm.FSRest.selectedIndex = 1;
- <%case else%>
- document.QForm.FSRest.selectedIndex = 0;
- <%end select%>
-
- <%select case FSRestVal%>
- <%case "any"%>
- document.QForm.FSRestVal.selectedIndex = 0;
- <%case "100"%>
- document.QForm.FSRestVal.selectedIndex = 1;
- <%case "1024"%>
- document.QForm.FSRestVal.selectedIndex = 2;
- <%case "10240"%>
- document.QForm.FSRestVal.selectedIndex = 3;
- <%case "102400"%>
- document.QForm.FSRestVal.selectedIndex = 4;
- <%case "1048576"%>
- document.QForm.FSRestVal.selectedIndex = 5;
- <%case "10485760"%>
- document.QForm.FSRestVal.selectedIndex = 6;
- <%case "104857600"%>
- document.QForm.FSRestVal.selectedIndex = 7;
- <%case "other"%>
- document.QForm.FSRestVal.selectedIndex = 8;
- <%case else%>
- document.QForm.FSRestVal.selectedIndex = 0;
- <%end select%>
-
- document.QForm.FSRestOther.value = "<%=FSRestOther%>";
-
- <%select case FMMod%>
- <%case "any"%>
- document.QForm.FMMod.selectedIndex = 0;
- <%case "-10n"%>
- document.QForm.FMMod.selectedIndex = 1;
- <%case "-1h"%>
- document.QForm.FMMod.selectedIndex = 2;
- <%case "-1d"%>
- document.QForm.FMMod.selectedIndex = 3;
- <%case "-1w"%>
- document.QForm.FMMod.selectedIndex = 4;
- <%case "-1m"%>
- document.QForm.FMMod.selectedIndex = 5;
- <%case "-1y"%>
- document.QForm.FMMod.selectedIndex = 6;
- <%case "since"%>
- document.QForm.FMMod.selectedIndex = 7;
- <%case else%>
- document.QForm.FMMod.selectedIndex = 0;
- <%end select%>
-
- document.QForm.FMModDate.value = "<%=FMModDate%>";
-
- document.QForm.DocAuthorRestriction.value = "<%=DocAuthorRestriction%>";
- }
- //-->
- </SCRIPT>
-
- <FORM NAME="QForm" ACTION="advsqlq.asp" METHOD=POST>
-
- <table width=500>
-
- <tr>
- <td>Enter your query: </td>
- <td><INPUT TYPE="TEXT" NAME="SearchString" SIZE="70" MAXLENGTH="100" VALUE=""></td>
- <tr>
-
- <tr>
- <td colspan=2 align=right>Document author:
- <INPUT TYPE="TEXT" NAME="DocAuthorRestriction" SIZE="47" MAXLENGTH="100" VALUE="">
- </tr>
-
- <tr>
- <td colspan=2 align="right">Where File Size is:
- <SELECT NAME="FSRest">
- <!-- <OPTION VALUE=" < " <%if FSRest = " < " then%>SELECTED <%end if%>>Less Than
- <OPTION VALUE=" > " <%if FSRest = " > " then%>SELECTED <%end if%>>Greater Than
- -->
- <OPTION VALUE=" < " SELECTED>Less Than
- <OPTION VALUE=" > " >Greater Than
- </SELECT>
-
- <SELECT NAME="FSRestVal" DEFAULT VALUE="any">
- <OPTION VALUE="any" SELECTED>any size
- <OPTION VALUE="100" >100 bytes
- <OPTION VALUE="1024" >1K bytes
- <OPTION VALUE="10240" >10K bytes
- <OPTION VALUE="102400" >100K bytes
- <OPTION VALUE="1048576" >1M byte
- <OPTION VALUE="10485760" >10M bytes
- <OPTION VALUE="104857600" >100M bytes
- <OPTION VALUE="other" >Other
- </SELECT>
- <INPUT TYPE="TEXT" NAME="FSRestOther" SIZE="12" MAXLENGTH="9" VALUE="">
- </td>
- </tr>
-
- <tr>
- <td colspan=2 align="right">Modified:
- <SELECT NAME="FMMod">
- <OPTION VALUE="any" SELECTED >at any time.
- <OPTION VALUE="DATEADD(minute, -10, GETGMTDATE())">in the last 10 minutes.
- <OPTION VALUE="DATEADD(hour, -1, GETGMTDATE())">in the last hour.
- <OPTION VALUE="DATEADD(day, -1, GETGMTDATE())">in the last day.
- <OPTION VALUE="DATEADD(week, -1, GETGMTDATE())">in the last week.
- <OPTION VALUE="DATEADD(month, -1, GETGMTDATE())">in the last month.
- <OPTION VALUE="DATEADD(quarter, -1, GETGMTDATE())">in the last quarter.
- <OPTION VALUE="DATEADD(year, -1, GETGMTDATE())">in the last year.
- <OPTION VALUE="since">since GMT (yy/mm/dd) .
- </SELECT>
- <INPUT TYPE="TEXT" NAME="FMModDate" SIZE="12" MAXLENGTH="9" VALUE="">
- </td>
- </tr>
-
- <tr>
- <td colspan=2, align=right>
- <INPUT TYPE="SUBMIT" NAME="Action" VALUE="Execute">
- <INPUT TYPE="RESET" NAME="Clear" VALUE="Clear">
- </td>
- </tr>
- </table>
-
- <INPUT TYPE="HIDDEN" NAME="SortBy" VALUE=" order by rank desc">
- <INPUT TYPE="HIDDEN" NAME="ColChoice" VALUE="1">
- <INPUT TYPE="HIDDEN" NAME="CiMaxRecords" VALUE="10">
-
- </FORM>
-
- <BR>
-
- <%if DebugFlag then%>
- <PRE>
- SearchString = <%=SearchString%>
- DocAuthorRestriction = <%=DocAuthorRestriction%>
- FSRest = <%=FSRest%>
- FSRestVal = <%=FSRestVal%>
- FSRestOther = <%=FSRestOther%>
- FMMod = <%=FMMod%>
- FMModDate = <%=FMModDate%>
- SortBy = <%=SortBy%>
- Colset = <%=Colset%>
- NewQuery = <%=CStr(NewQuery)%>
- Maximum Records = <%=CiMaxRecords%>
- </PRE>
- <%end if%>
-
- <%
- SelectColumns = "DocTitle, vpath, path, filename, size, write, characterization"
- SelectString = "Select " + SelectColumns + " from Scope() "
- if NewQuery then
- set AdoConnection = Server.CreateObject("ADODB.Connection")
- set AdoCommand = Server.CreateObject("ADODB.Command")
- AdoConnection.ConnectionString = "provider=msidxs"
- AdoConnection.Open
- set AdoCommand.ActiveConnection = AdoConnection
-
- Composer = ""
- TheQuery = ""
-
- if SearchString <> "" then
- TheQuery = "contains('""" + SearchString + """')>0"
- Composer = " and "
- end if
-
- if FSRestVal <> "any" then
- if FSRestVal <> "other" then
- if FSRestVal <> "" then
- TheQuery = "Size " + FSRest + FSRestVal + " " + Composer + TheQuery
- end if
- else
- TheQuery = "Size " + FSRest + FSRestOther + " " + Composer + TheQuery
- end if
-
- Composer = " and "
- end if
-
- if DocAuthorRestriction <> "" then
- TheQuery = "Contains(DocAuthor, '""" + DocAuthorRestriction + """')>0 " + Composer + TheQuery
- Composer = " and "
- end if
-
- if FMMod <> "" AND FMMod <> "any" then
- if FMMod <> "since" then
- TheQuery = "(Write > " + FMMod + ") " + Composer + TheQuery
- else
- TheQuery = "(Write > '" + FMModDate + "') " + Composer + TheQuery
- end if
- end if
-
- if TheQuery <> "" then
- SelectString = SelectString + " where " + TheQuery +" "+ SortBy
- else
- SelectString = SelectString + SortBy +" "
- end if
-
- AdoCommand.CommandText = SelectString
- set RS = Server.CreateObject("AdoDB.Recordset")
- RS.CursorType = adOpenStatic
- RS.MaxRecords = CiMaxRecords
- RS.Open AdoCommand
-
- ' Display Recordset Contents.
- if not RS.EOF then
- %>
-
- <p>
- <HR WIDTH=80% ALIGN=center SIZE=3>
- <p>
-
- <%
- Response.Write "Results matching the query " & chr(34) & "<I>"
- Response.Write SelectString & "</I>" & chr(34) & ".<P>"
- %>
- <!-- If the index is out of date, display the fact -->
- <%if GetCiOutofDate(RS.Properties("Rowset Query Status")) then%>
- <P>
- <I><B>The index is out of date.</B></I><BR>
- <%end if%>
-
- <!--
- 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 GetCiQueryIncomplete(RS.Properties("Rowset Query Status")) 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 GetCiQueryTimedOut(RS.Properties("Rowset Query Status")) then%>
- <P>
- <I><B>The query took too long to complete.</B></I><BR>
- <%end if%>
-
- </PRE>
- <!-- BEGIN column header -->
-
- <!-- BEGIN first row of query results table -->
- <P> Printing Results.
- <TABLE>
- <%
- Do While Not RS.EOF and NextRecordNumber < 10 %>
-
- <%
- ' 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+1%>.
- <%if VarType(RS("DocTitle")) = 1 or RS("DocTitle") = "" then%>
- <b><a href="<%=RS("vpath")%>"><%= Server.HTMLEncode( RS("filename") )%></a></b>
- <%else%>
- <b><a href="<%=RS("vpath")%>"><%= Server.HTMLEncode(RS("DocTitle"))%></a></b>
- <%end if%>
- <dd>
- <%if VarType(RS("characterization")) = 8 and RS("characterization") <> "" then%>
- <b><i>Abstract: </I></b><%= Server.HTMLEncode(RS("characterization"))%>
- <br>
- <%end if%>
- <cite>
- <a href="<%=RS("vpath")%>">http://<%=Request("server_name")%><%=RS("vpath")%></a>
- <font size=-1> - <%if RS("size") = "" then%>(size and time unknown)<%else%>size <%=RS("size")%> bytes - <%=RS("write")%> GMT<%end if%></font>
- </cite>
-
- <%
- RS.MoveNext
- NextRecordNumber = NextRecordNumber+1
- Loop
- %>
- </TABLE>
-
-
- <P><BR>
-
- <%
- end if ' NOT RS.EOF
- %>
-
-
- <%
- ' If either of the previous or back buttons were displayed, save the query
- ' and the recordset in session variables.
- RS.close
- AdoConnection.Close
- Set RS = Nothing
- Set AdoCommand = Nothing
- Set AdoConnection = Nothing
- end if 'New Query
- %>
-
- <!--#include file ="is2foot.inc"-->
-
- </BODY>
- </HTML>
-
-