欢迎光临
我们一直在努力

5个实用网站速成(BIG5)(四)

建站超值云服务器,限时71元/月

網站如何加入中文全文檢索功能呢?

如何於您的網站加入中文全文檢索功能呢?

於windows nt option pack當中,包括index server,提供中文全文檢索的搜尋功能,可以搜尋網站中microsoft word 或microsoft excel檔案、text、html、asp等檔案格式內的資料。

本單元教您如何搜尋特定目錄下的資料。

若要執行中文全文檢索的範例,首先安裝windows nt option pack的microsoft index server,然後於index server manager建立一個名為ntop的catalog。

方法為執行index server manager,於 [index server on local machine] 按右鍵,選擇 [new] 的 [catalog]。

接著將catalog命名為ntop,選擇範例安裝的路徑,建立待搜查的目錄,於所新建立的ntop catalog,按右鍵,選擇 [new] 的 [directory],輸入待搜查的目錄,最後要啟動index server,於 [index server on local machine] 按右鍵,選擇 [start]。

於用戶端使用瀏覽器執行,輸入搜尋字串index。

所找到的標題為本範例的<title>您找到index server了</title>。

如何於asp程式加入中文全文檢索功能呢?首先set q = server.createobject("ixsso.query")以呼叫中文全文檢索的元件,然後設定:

q.query = 搜尋字串

q.sortby = 排列順序

q.columns = 搜尋的欄位

q.catalog = 搜尋的catalog

q.maxrecords = 最多搜尋筆數

最後下一行q.createrecordset("nonsequential")後即開始搜尋,搜尋的結果放在rs的recordset中,如下:

rs.recordcount:搜尋相符的筆數。

rs("rank"):搜尋相符率,最大為1000。

rs("doctitle"):標題。

rs("vpath"):url位址。

rs("characterization"):摘要。

rs("size"):檔案大小。

rs("filename"):檔案名稱。

rs("write"):檔案寫入日期時間。

完整的asp程式如下:

<html><head>

<title>您找到index server了</title>

</head>

<body>

<%

if request("action") = "搜尋" then

set q = server.createobject("ixsso.query")

q.query = request("searchstring")

q.sortby = "rank[d]"

q.columns = "doctitle, vpath, filename, size, write,

characterization, rank"

q.maxrecords = 50

q.catalog = "ntop"

set rs = q.createrecordset("nonsequential")

response.write "總計 " & rs.recordcount & " 項<p>"

%>

<% do while not rs.eof %>

<%if vartype(rs("doctitle")) = 1 or rs("doctitle") = "" then%>

<a href="<%=rs("vpath")%>"><%=

server.htmlencode( rs("filename") )%></a> (<%= rs("rank") %>)

<%else%>

<a href="<%=rs("vpath")%>"><%= server.htmlencode(rs("doctitle"))%></a> (<%= rs("rank") %>)

<%end if%>

<br>

<%if vartype(rs("characterization")) = 8 and rs("characterization") <> "" then%>

摘要:<%= server.htmlencode(rs("characterization"))%><br>

<%end if%>

http://<%=request("server_name")%><%=rs("vpath")%><br>

<%if not rs("size") = "" then%>

size <%=rs("size")%> bytes – <%=rs("write")%> gmt

<%end if%>

<p>

<%

rs.movenext

loop

end if

%>

<hr>

<form action="index1.asp" method=get>

搜尋字串:

<input type="text" name="searchstring" size="30" value="<% = request("searchstring") %>"></td>

<input type="submit" name="action" value="搜尋">

</form>

<hr></body></html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 5个实用网站速成(BIG5)(四)
分享到: 更多 (0)