答案:<%@ Language=VBScript %>
<%
Response.Expires = 0
Response.Buffer = false
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Indexing Service</TITLE>
<style type="text/css">
body, p, div, th, td, br, a, input, textarea, select
{
font-family: "Tahoma", "宋体";
font-size: "12px";
}
a:link
{
color: "#336699";
text-decoration: none;
}
a:visited
{
color: "#6699CC";
text-decoration: none;
}
a:hover
{
color: "#996633";
text-decoration: underline;
}
</style></HEAD>
<%
work=request("work")
if work<>"search" then
%>
<BODY scroll=no>
<TABLE cellSpacing=1 cellPadding=1 width="100%" border=1>
<form action=default.Asp method=get name=Index target="result">
<INPUT type="hidden" name=work value="search">
<TR>
<TD bgColor=#ffff99>
<P>Search for: <INPUT id=keyword name=keyword size=50>
<select name="stype">
<option value="1" selected>一般</option>
<option value="2">精确</option>
<option value="4">模糊</option>
</select>
<select name="pagesize">
<option value="10">10</option>
<option value="20" selected>20</option>
<option value="30">30</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="500">500</option>
<option value="all">All</option>
</select>
<INPUT type=submit value="Perform"> <INPUT style="LEFT: 285px; TOP: 41px" type=reset value="Clear"></P></TD>
</TR>
<tr>
<td>
<iframe src=about:blank border=0 frameborder=0 id=result name=result height=350 width=100%></iframe>
</td>
</tr>
</form>
</TABLE>
<HR>
(C) 2001 <U>Chen Wei</U> - <STRONG>Windows 2000 Server Indexing Service Demo v1.0</STRONG>
<%else
Response.Write "<BODY>"
dim keyword
dim stype
dim pagesize
oldkeyword = Request("keyword")
keyword = replace(oldkeyword,"'","''")
function clen(str)
For i = 1 To Len(str)
zh = Mid(str, i, 1)
zhasc = Asc(zh)
If zhasc < 0 Then
clen=false
exit function
End If
Next
if len(str)<3 then clen=true else clen=false
end function
if clen(keyword) then
Response.Write "没有任何结果 - 关键字必须 > 3(英文) or > 1(中文)。"
Response.End
end if
stype = cstr(Request("stype"))
pagesize = Request("pagesize")
dim page
page = clng(request("page"))
if page<1 then page=1
if keyword <> "" then
dim con, rs
set con = server.CreateObject("adodb.connection")
set rs = server.CreateObject("adodb.recordset")
dim strSearchSQL
select case stype
case "1"
strSearchSQL = "select DocTitle, vPath, FileName, Characterization, Size, Rank from scope() where contains('" & keyword & "') order by Rank Desc"
case "2"
strSearchSQL = "select DocTitle, vPath, FileName, Characterization, Size, Rank from scope() where freetext('" & keyword & "') order by Rank Desc"
case "4"
strSearchSQL = "select DocTitle, vPath, FileName, Characterization, Size, Rank from scope() where contains('formsof(INFLECTIONAL,""" & keyword & """)') order by Rank Desc"
end select
'Response.Write stype & strSearchSQL
con.Open "Provider=MSIDXS; Data Source=Web"
rs.Open strSearchSQL, con, 3
if pagesize="all" then pagesize = rs.RecordCount
pagesize=clng(pagesize)
rs.PageSize = pagesize
if page> rs.PageCount then page=rs.PageCount
if not rs.BOF then
上一个:index server example
下一个:SQL Server同Index Server的结合应用2/3——选自《用BackOffice建立Intranet/Extranet应用》一书