分享
 
 
 

全文搜索引擎的源代码

王朝英语沙龙·作者佚名  2007-01-10
窄屏简体版  字體: |||超大  

这是用ASP编写的利用Windows2000Server中的Index Server控件的全文搜索引擎的源代码:

Sub Initialize()

'指定搜寻范围

SearchScope = "/"

'设定LCID(Locale Identifier)

LocaleID = "ZH-CN"

'指定每一页的资料笔数

PageSize = 10

'设定其余变数

NewQuery = FALSE

UsedQuery = FALSE

QryStr = ""

'取得ASP文件的虚拟路径,包括文件名

ASPFile = Request.ServerVariables("PATH_INFO")

End Sub

Sub Judge_Method()

if Request.ServerVariables("REQUEST_METHOD") = "POST" then

QryStr = Request.Form("QryStr")

action=Request.Form("Action")

if Request.Form("Action") = "执行" then

NewQuery = TRUE '为一新查询

end if

end if

if Request.ServerVariables("REQUEST_METHOD") = "GET" then

QryStr = Request.QueryString("qu")

SearchScope = Request.QueryString("sc")

if Request.QueryString("pg") <> "" then

NextPgNo = Request.QueryString("pg")

NewQuery = FALSE

UsedQuery = TRUE

else

NewQuery = QryStr <> ""

end if

end ifEnd Sub

Sub Show_Mainform()

Response.Write "<INPUT TYPE='TEXT' NAME='QryStr' SIZE=46 "

Response.Write "MAXLENGTH=100 VALUE='" & QryStr & "'> "

Response.Write "<INPUT TYPE='SUBMIT' NAME='Action'"

Response.Write " VALUE='执行'> "

Response.Write "<INPUT TYPE='RESET' NAME='Clear'"

Response.Write " VALUE='清除'>"

Response.Write "</div>"

Response.Write "</td>"

Response.Write "</tr>"

Response.Write "</table>"

Response.Write "<hr></FORM>"

End Sub

Sub Init_ixsso()

Dim StrLen

if NewQuery then '若为新查询

Set Session("Query") = Nothing

Set Session("Recordset") = Nothing

NextRecNo = 1

'去除查询字符串中的左、右双引号(如果有的话)

StrLen = len(QryStr)

if left(QryStr, 1) = chr(34) then

StrLen = StrLen - 1

QryStr = right(QryStr, StrLen)

end if

if right(QryStr, 1) = chr(34) then

StrLen = StrLen - 1

QryStr = left(QryStr, StrLen)

end if

Set Q = Server.CreateObject("ixsso.Query")

Set util = Server.CreateObject("ixsso.Util")

Q.Query = QryStr

Q.SortBy = "rank[d]"

Q.Columns = "DocTitle, vpath, filename, size, write, characterization, rank"

Q.MaxRecords = 200

if SearchScope <> "/" then

util.AddScopeToQuery Q, SearchScope, "deep"

end if

if LocaleID <>"" then

Q.LocaleID = util.ISOToLocaleID(LocaleID)

end if

set RS = Q.CreateRecordSet("nonsequential")

RS.PageSize = PageSize

ActiveQuery = TRUE

ElseIf UsedQuery then

if IsObject( Session("Query") ) And _

IsObject( Session("RecordSet") ) then

set Q = Session("Query")

set RS = Session("RecordSet")

if RS.RecordCount <> -1 and NextPgNo <> -1 then

RS.AbsolutePage = NextPgNo

NextRecNo = RS.AbsolutePosition

end if

ActiveQuery = TRUE

else

Response.Write "错误 - 尚无任何查询条件!"

end if

End If 'NewQueryEnd Sub

Sub Show_Query()

Dim LastRecordOnPage

'若为现有查询

if ActiveQuery then

'如果Record set有值,就一一取出,然后显示于前端浏览器

if not RS.EOF then

LastRecordOnPage = NextRecNo + RS.PageSize - 1

CurrentPage = RS.AbsolutePage

if RS.RecordCount <> -1 AND _

RS.RecordCount < LastRecordOnPage then

LastRecordOnPage = RS.RecordCount

end if

'显示视窗目前的资料编号

Response.Write "文件" & NextRecNo & " 至 "

Response.Write LastRecordOnPage & ", "

'取出总笔数

if RS.RecordCount <> -1 then

Response.Write "总共有<font color='red'><b>"

Response.Write RS.RecordCount & "</b></font>"

end if

Response.Write "笔纪录符合查询条件:" & chr(34) & "<b>"

Response.Write QryStr & "</b>" & chr(34) & "。<P>"

if Not RS.EOF and NextRecNo <= LastRecordOnPage then

Response.Write "<table border=0>"

Response.Write "<colgroup width=105>"

end if

Do While Not RS.EOF and NextRecNo <= LastRecordOnPage

'一一显示文件的标题、摘要、URL、文件大小及

'最后修改日期。

Response.Write "<center>"

Response.Write "<p>"

Response.Write "<tr class='RecordTitle'>"

Response.Write "<td align=center valign=top "

Response.Write "BGCOLOR='#EEEEEE' class='RecordTitle'>"

'显示编号

Response.Write NextRecNo & "."

Response.Write "</td>"

Response.Write "<td BGCOLOR='#EEEEEE'>"

Response.Write "<b class='RecordTitle'>"

'如果标题属性(Title)存在的话就显示Title,

'否则显示出文件名

if VarType(RS("DocTitle")) = 1 or RS("DocTitle") = "" then

Response.Write "<a href='" & RS("vpath") & "' "

Response.Write "class='RecordTitle'>"

Response.Write Server.HTMLEncode(RS("filename")) & "</a>"

else

Response.Write "<a href='" & RS("vpath") & "' "

Response.Write "class='RecordTitle'>"

Response.Write Server.HTMLEncode(RS("DocTitle")) & "</a>"

end if

Response.Write "</b>"

Response.Write "</td></tr>"

Response.Write "<tr>"

Response.Write "<td>"

Response.Write "</td>"

Response.Write "<td valign=top>"

'显示摘要

if VarType(RS("characterization")) = 8 and _

RS("characterization") <> "" then

Response.Write "<b>摘要:</b>"

Response.Write Server.HTMLEncode(RS("characterization"))

end if

Response.Write "<p>"

Response.Write "<a href='"

Response.Write RS("vpath") & "' class='RecordStats' "

Response.Write "style='color:blue;'>http://"

Response.Write Request("server_name") & RS("vpath")

Response.Write "</a><br>"

if RS("size") = "" then

Response.Write "(大小和时间不详)"

else

Response.Write "大小 " & RS("size") & " 个字节 - "

Response.Write RS("write") & " GMT"

end if

Response.Write "</td></tr>"

Response.Write "<tr></tr>"

RS.MoveNext

NextRecNo = NextRecNo + 1

Loop

Response.Write "</table>"

Response.Write "<P><BR>"

else ' RS.EOF

if NextRecNo = 1 then

Response.Write "没有任何文件符合查询条件!<P>"

else

Response.Write "符合查询条件的文件均已显示!<P>"

end if

end if ' NOT RS.EOF

if Q.OutOfDate then

Response.Write "<P><B>检索即将过期"

Response.Write "(out of date)。</B><BR>"

end if

if Q.QueryIncomplete then

Response.Write "<P><B>查询无法完整完成"

Response.Write "(Query Incomplete)。</B><BR>"

end if

if Q.QueryTimedOut then

Response.Write "<P><B>查询时间太长"

Response.Write "(Time out)。</B><BR>"

end if

'

Call Show_Button()

end if 'ActiveQueryEnd Sub

</script>

<HTML>

<HEAD>

<META NAME="MS.LOCALE" CONTENT="ZH-CN">

<META HTTP-EQUIV="Content-Type" CONTENT="text/html">

<TITLE>站内全文检索引擎</TITLE>

<LINK REL=Stylesheet TYPE="text/css" HREF="ews.css">

<%

'搜寻范围

Call Initialize()

'判断Request_Method

Call Judge_Method()

%>

</HEAD>

<BODY background="/images/marble2c.GIF" >

<right>

<%response.write ""&action&""%>

<%

Call Show_Mainform()

Call Init_ixsso()

Call Show_Query()

%>

</right>

</BODY></HTML>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有