Using ASP to access the index server of Web search engine

Source: Internet
Author: User
Tags define comparison file size implement key words
Absrtact: Index Server is a professional search engine designed specifically for enterprise Web sites, and traditional access methods html/idq/htx due to inherent characteristics and lack of flexibility. This paper introduces two methods of using ASP to access the index server, and how to implement complex query and control the result of query.
Keywords: Index Server ASP ADO

In the ascendant of E-commerce today, the Internet is not only to display corporate image, improve visibility, but also means endless business opportunities and wealth. Intranet, however, brings new communication and management concepts to the enterprise. As a result, building a corporate web site has been scheduled for many enterprise information departments. The advantage of the web is that it can easily display a large amount of information, but it also brings about a deluge of information that makes it difficult to find effective information. To this end, good corporate websites have a strong search engine, making the site more friendly and convenient. For a large number of documents such as policy regulations, contract orders and other websites, information Search service is essential.
The Index server is a specialized search engine designed for corporate websites, and it makes it easy to add powerful information search capabilities to your site. and Index Server search files are not limited to HTML format, but also support TXT, DOC, EXL, RTF, GIF, JPEG and other file formats, and can be inserted into Third-party plug-ins to support more file formats. The search scope can be content that resides on the local server, or it can be a shared resource for other machines on the network, including resources on the Internet. You can search for attributes such as file size, date modified, author, and so on, in addition to the key words in your document. In addition, the Index server also supports languages such as English, Simplified Chinese, German, French, and Japanese, and you can implement a multilingual search engine on your Web site without programming. Because the index server is a 0 maintenance design, the search engine will run automatically only if you start the Index Server service. On the Web server side, you need to join the page that is connected to the index server.
The traditional Index server's work process is initiated by the browser through the form table of the HTML document to the Web server, and the Web server passes a specialized file similar to the database interface. IDQ with Index Server to convert customer's request to index The statement that the server understands. The Index server then organizes the query results into an HTML document in the format defined by the template file htx, which is returned to the browser through the Web server. This approach, called HTML/IDQ/HTX, requires three files to work with to complete the query. The query results cannot be processed using this method, and the template file htx in a single format. So Microsoft has added support for active Server scripts in index Server 2.0, replacing the previous three files with an ASP file. Because the ASP has flexible and powerful scripting language manipulation, Web developers can design complex queries and handle query results more accurately.

Figure 1. ASP access to the Index server work process
Users who are familiar with the Index Server 1.0 or version 1.1 can use the Index Server query object in an ASP file, both objects parameters and query statements, and traditional. IDQ file consistency. In addition, you can create objects using ADO technology and define queries using standard database query Language Structured Query Language (SQL) statements. Both objects return results in the form of an ADO recordset (recordsets). Therefore, the code for the database recordset operation can be used directly for query results.
ASP file to complete the query, first of all to define a form in the file to receive the query request, the action of the form point to the ASP file itself. In this example, the query field is received with a text box named SearchString.
Eg.1 define a query form in the sample. asp file

<form ACTION = "Sample. asp" method= "get" >
<table >
<TR>
<TD> Input Search Keywords:</td>
</TR>
<TR>
<td><input type= "TEXT" name= "searchstring" size= "value=" "></TD>
<td><input type= "SUBMIT" value= "Go" ></TD>
</TR>
</TABLE>


Next, create the Index Server query object in the ASP file and assign a value to the index Server parameter.
Method 1. Use index Server query object and Parameters

<%
Set q= sever.creatobject ("Ixsso.") Query ")" to create the object
Set util= sever.creatobject ("Ixsso.") Util ")
q.query= request ("searchstring") ' Query field
Q.sortby= "rank[d]" ' in descending order of compliance
Q.columns= "Doctitle,vpath,filename,size,write,characterization,rank"
' Return record Properties
Q.maxrecords=300 ' Maximum number of records returned
Util.addscopetoquery Q, "/", "DEEP" Search all subdirectories
Q.localeid=util.isotolocaleid ("ZH-CN") ' Specifies the language used for Simplified Chinese
Set RS = Q.createrecordset ("nonsequential") ' Create output set
%>

Method 2. Using ADO Query object and SQL statements

<%
Set Conn = Server.CreateObject ("ADODB. Connection ")
conn.connectionstring = "PROVIDER=MSIDXS;"
Conn.Open
Set Adocommand = Server.CreateObject ("Adodb.command")
Set adocommand.activeconnection = Conn
Adocommand.commandtext = "Select Doctitle,vpath,filename,size,write," &
"Characterization,rank from SCOPE () WHERE CONTAINS (" &
SearchString & "') Order by rank DESC"
Set RS = Server.CreateObject ("ADODB.") RecordSet ")
Rs.Open Adocommand
%>

To create a query that includes complex criteria for attributes such as file size, author, and so on, you can include fields that enter the appropriate qualifying criteria in the form, as shown in Figure 2.

Figure 2. Complex query form with qualified conditions
After submitting the form, the values are received by the query statement, such as one of the following query statements:
Q. query= "(@DocAuthor" + Docauthorrestriction + ") & (@Write >" +
Fmmoddate + ") & (@Size" + fsrest + fsrestval + ") & @Contenets" +
SearchString

Among them, Docauthorrestriction, Fmmoddate, Fsrest, Fsrestval, searchstring represent the author, modification time, comparison symbol, comparison size and key word equivalence of the browser-side input respectively. Additionally, the Index Server supports natural language queries (free Text Queries), such as an input statement: "How do I use the Index Server management tool?" ”。 and add the tag $ contenets to the query field. The Index server will perform parsing and automatically generate query statements.
As mentioned earlier, both query objects return the result of an ADO recordset (recordsets), so you can manipulate the output with a data pointer.
EG.2 defines the output format in the sample. asp file

<% if not RS. EOF%>
<table border=0>
<colgroup width=105>
<% End If%>

<% do, not RS. EOF%>
<tr>
&LT;TD valign=top >
<a href= "<%=rs (" Vpath ")%>" ><%= Server.HTMLEncode (RS ("filename")%>
</a></td>
&LT;TD valign=top>
<%if VarType (RS ("characterization") = 8 and RS ("characterization") <> "" Then%>
<b><I> Summary </i></b><%= Server.HTMLEncode (RS ("characterization"))%>
<%end if%>
<p><a href= "<%=rs (" Vpath ")%>" >http://<%=request ("SERVER_NAME")%>
<%=rs ("Vpath")%></a></p>
</td>
</tr>
<%
Rs. MoveNext
Loop
%>
</table>

As needed, you can also output attributes such as author, file size, creation time, and so on. It is also common to classify files into five levels, with different numbers of star map IDs, which is a feature that traditional HTX documents cannot achieve.
Combined with ASP and Index Server, we can develop powerful search engine applications. Implementation is simple and convenient, no special programming requirements, and search speed and accuracy is also ideal, very suitable for enterprise-class web site adoption.




Related Article

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.