如何?全文檢索索引?

來源:互聯網
上載者:User

<%@ LANGUAGE="VBscript" %>
  <html>
  <head>
  <meta NAME="GENERATOR" Content="Microsoft FrontPage 3.0">
  <meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb_2312-80">
  <title>星河影動之全文檢索索引</title>
  <meta name="Microsoft Border" content="tl, default">

</head>
   <body BGPROPERTIES="FIXED" BGCOLOR="#00FFFF">

<%
  mousepointer=13
  Set Conn1 = Server.CreateObject("ADODB.Connection")
  conn1.open "DSN=intels"
  Set rcst1 = conn1.execute("select * from pages_catalogue")
  sch_str=request.form("text1")
  doubbytes=len(sch_str)\2
  sch_str=left(sch_str,doubbytes)

' 匹配字串的長度.預先處理Request取得的資料(使用者輸入的有用資訊), 通過計算有效資訊長度來截取所需的字串.我們也可以在輸入字串後附加一標誌字元(如#或chr(7))來處理.
  Response.Write "<CENTER>檢索結果<HR><Br>"
  Dim result
  result =false
  Response.Write "<UL>"
  do while not rcst1.eof
  tit=rcst1.fields("file_title")
  fn=rcst1.fields("file_name")
  file_name= Server.MapPath ("/") & "\song\chunfeng\" & fn
  to_find=text_match(file_name,sch_str)

' 逐個開啟記錄集中目前記錄所指向的檔案。用尋找的字串對檔案的全文本進行匹配比較.
  if to_find then
  url="chunfeng/" & fn
  Response.Write "<A HREF=" & url & ">
" & tit
  end if
  rcst1.movenext
  result=result or to_find
  loop
  Response.Write "</UL>"

' 把合格檔案標題以超級連結形式輸出到用戶端.
  if not result then
  Response.Write "對不起,沒有找到!"
  end if
  mousepointer=0
  %>
  <script RUNAT="Server" LANGUAGE="VBScript">
  function text_match(filename,search_string)
  dim retstring
  dim find_pos
  Dim fso, a
  dim done
  text_match=false
  Set fso = Server .CreateObject("Scripting.FileSystemObject
")

' 建立指令碼的檔案系統,開啟文字資料流以讀入.
  Set a = fso.OpenTextFile(filename, 1, FALSE)

done=a.AtEndOfStream or text_match
  Do While not done
  retstring = a.ReadLine
  find_pos=instr(retstring,search_string)
  if find_pos>0 then text_match=true
  done=a.AtEndOfStream or text_match
  Loop
  a.Close
  end function
  </script>
  </body></html>

[1]

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.