配置index server
在执行web服务器上的搜索之前,首先必须创建至少一个索引,并遵循以下步骤完成这项工作。
⒈启动windows 2000 server服务器上的索引。
缺省情况下选择图标位于管理工具组中的计算机管理。窗口的右边提供关于当前在服务器上
存在的索引信息。默认有两个索引:system和web。
⒉要创建新的索引,用鼠标右键单击索引服务或右边的面板,选定新建编录。
显示添加编录对话框,指定索引的名称并用浏览按钮选取位置。索引服务不会立即开始索引,此时将弹出一条消息框,单
击确定继续。为了达到最佳的性能,索引服务可以放在和web服务器隔离开的硬盘上。
⒊指定索引的目录,用右键单击新建的编录名,从弹出选单中选定属性,将出现如图2所示的对话框。
第一个选项卡常规显示刚刚输入的内容,在第二个选项卡跟踪中的www服务器下拉列表中选取你要索引的web网站。
⒋有了创建的编录,现在可以挑选你想在索引中包括的目录。
这个强大的特性使你能创建几个用不同方式搜索内容的索引。例如,你可能想快速浏览从完整的文本中所引出的章节,这
个特性使你能在index server内执行这项任务。要添加一个目录,用右键单击右边的面板,选定新建目录。在出现的对话
框中通过浏览按钮选择目录并指定别名。如果必须登录到服务器才能得到需要的内容,则可以提供将使用的用户名和密
码,以便得到需要的内容。如果想检查受保护的内容,则更要维护内容的安全性,这一特性非常有用,这样只有被授权的
用户(也许是那些为此付钱的人)才能得到完整的内容。
还可以使用这个工具排除web站点中不想索引的子目录。例如,检索scripts/cgi目录就不会对用户有什么用。为此,只要
双击该目录,将包括在索引中选定为否即可,见图3。
⒌在已经为站点包括/排除了所有目录后,用右键单击右面板,从弹出选单中选定启动,重新启动index server服务。
服务器将开始浏览已经创建的索引并开始检索内容。
源程序:
1、search.asp
<html>
<head>
<title>the indexing service</title>
<style type="text/css">
body {font-family:tahoma,arial,sans-serif; font-size:10pt}
.heading {font-family:tahoma,arial,sans-serif; font-size:14pt; font-weight:bold}
.cite {font-family:tahoma,arial,sans-serif; font-size:8pt}
</style>
</head>
<body bgcolor="#ffffff">
<span class="heading">searching the indexing service using ado</span><hr>
<!—————————————————————————>
<form name="frmsearch" action="queryindexserver.asp" method="post">
search for: <input type="text" name="txtsearchfor">
<p>
<input type="submit" value="perform search">
<input type="reset" value="clear form">
</form>
</body>
</html>
2、queryindexserver.asp
<title>the indexing service</title>
<style type="text/css">
body {font-family:tahoma,arial,sans-serif; font-size:10pt}
.heading {font-family:tahoma,arial,sans-serif; font-size:14pt; font-weight:bold}
.cite {font-family:tahoma,arial,sans-serif; font-size:8pt}
.document {font-size:10pt; font-weight:bold; background-color:lightgrey; width:100%}
</style>
</head>
<body bgcolor="#ffffff">
<span class="heading">results of search for
<i><%=request.form("txtsearchfor")%></i>
</span><hr>
<!—————————————————————————>
<%
dim strsearch
set rssearch = server.createobject("adodb.recordset")
create the connection string
strconn = "provider=msidxs; data source=web"
construct the search string
strsearch = "select doctitle, path, filename, characterization, size,write" & _
" from scope()" & _
" where contains (" & request.form("txtsearchfor") & ")"
open the recordset on the search
rssearch.open strsearch,strconn
show whats been searched for
while not rssearch.eof
response.write "<span class=document>" & rssearch("doctitle") & "</span><br>" & _
rssearch("characterization") & "<br>" & _
"<a href=" & rssearch("path") & ">" & rssearch("write") & "</a>" & _
" (" & rssearch("size") & " bytes)<p>"
rssearch.movenext
wend
tidy up
rssearch.close
set rssearch = nothing
%>
</body>
</html>
采用默认的web索引!
