How to achieve full-text search

Source: Internet
Author: User
Tags file system microsoft frontpage
How to use ASP to realize full text search in the Web site?





we can first create a database that contains the file name, file title, and retrieve the file, then use ADO to access it and set up the Recordset object. See below for specific code and description:


<%@ language= "VBSCRIPT"%>


<html>


<head>


<meta name= "generator" content= "Microsoft FrontPage 3.0" >


<meta http-equiv= "Content-type" content= "text/html"; Charset=gb_2312-80 ">

Full-Text Search </title>
of
<title> wonderful spring Breeze

&lt;meta name= "Microsoft Border" content= "tl, default" &gt;


&lt;/head&gt;


&lt;body bgproperties= "FIXED" bgcolor= "#00FFFF" &gt;


&lt;%


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)


' matches the length of the string. Preprocessing the data obtained by the request (user input useful information), by calculating the length of effective information to intercept the required string. We can also attach a glyph (such as # or CHR (7)) to the input string after it is processed.


Response.Write "&lt;CENTER&gt; search results &lt;HR&gt;&lt;Br&gt;"


Dim Result


result =false


Response.Write "


"


do, not rcst1.eof


tit=rcst1.fields ("File_title")


fn=rcst1.fields ("file_name")


file_name= Server.MapPath ("/") &amp; "\song\chunfeng\" &amp; FN


To_find=text_match (FILE_NAME,SCH_STR)


' opens the file that the current record in the recordset points to. Match the Full-text text of a file with a search string to compare


......


Response.Write "&lt;a href=" &amp; URL &amp; "&gt;


"&amp; Tit


End If


Rcst1.movenext


Result=result or To_find


Loop


Response.Write "


"


' Output the eligible file headers to the client in hyperlink form


if not result then


Response.Write "Sorry, not found!"


End If


mousepointer=0


%&gt;


&lt;script runat= "Server" language= "VBScript" &gt;


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


")


' Create script file system, open text stream to read


Set a = fso. OpenTextFile (filename, 1, FALSE)


Done=a.atendofstream or Text_match


do


retstring = A.readline


find_pos=instr (retstring,search_string)


if Find_pos&gt;0 then Text_match=true


Done=a.atendofstream or Text_match


Loop


A.close


End Function


&lt;/script&gt;


&lt;/body&gt;


&lt;/html&gt;








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.