如何实现全文检索
2012-12-06 09:36
281 查看
<%@ 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>
<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>
相关文章推荐
- 如何实现小型WEB搜索引擎(C#+SQL Server全文检索+Asp.net)
- Mysql下的Web程序,如何实现全文检索
- 如何用C#实现数据库全文检索
- Mysql下的Web程序,如何实现全文检索
- 如何用java实现lucene(全文检索引擎)
- 如何实现小型WEB搜索引擎(C#+SQL Server全文检索+Asp.net)
- 【转】如何实现小型WEB搜索引擎(C# SQL Server全文检索 Asp.net)
- Elasticsearch使用REST API实现全文检索
- Lucene实现在线全文检索的总结
- 对二进制文件实现全文检索
- 仿造Baidu简单实现基于Lucene.net的全文检索的功能
- SQL2005实现全文检索的步骤
- asp.net C#.net操纵word,实现全文检索 ,.net word全文检索
- 近两年项目回顾系列——基于lucene+IKanalyzer实现全文检索
- 如何使用sql的全文检索功能
- Spring.net整合Lucene.net 实现全文检索(附例程)转载
- 如何将全文检索中的“干扰词”去除
- 关于jforum2.1.6的全文检索问题(采用lucene实现)
- 中科院罗平演讲全文:自动撰写金融文档如何实现,用 AI 解