Build an ASP Search Engine using Website Utility
page 3 of 3
by Brett Burridge
Feedback
Average Rating: 
Views (Total / Last 10 Days): 24731/ 24

Incorporating the ASP Search Facility into any Website

The Website Utility creates two ASP include files that can be used on the website's search results page:

  • A Search Data ASP include file (TWUSearchData_JScript.asp) contains the rankings for each word and the most relevant pages for that word.
  • A Search Code ASP include file (TWUSearchCode_JScript.asp) contains the code required to parse the user's search query and finds the most relevant pages for that query.

Note that the data and code files are created in JScript, but they can easily be used from within ASP pages that use VBScript.

Pages are sorted in search results according to their ranking for the particular word or words being searched for. The ranking scale goes from 0 to 99. Rank is higher for pages that most closely match the search term. In general, searching for words that are common on the site will produce search results with a lower rank than very specific words that occur on only one or two pages.

The search facility also requires a search form and a search results page. The search form can either be put on a separate search page on the site, or the search form could be added to all of the pages in a website (e.g. in the top right hand corner of the website's navigation). The HTML code for a typical search form is shown below. The search form needs a text box called TWUQuery. The form should use either the GET or POST form submission method to submit to the search results page.



ASP JScript Search for <a href="http://www.brettb.com/</title">http://www.brettb.com/</title</a>>
</head>
<body>
<h1>Search <a href="http://www.brettb.com/</h1">http://www.brettb.com/</h1</a>>
<form name="frmSearch" method="GET" action="searchresults.asp">


Search for: <input type="text" name="TWUQuery" maxlength="50">
<input type="submit" name="submitbutton" value="Submit">
</form>


</body>
</html></pre></p>
<p><font face="Verdana" size="2">The search results page (i.e. searchresults.asp) needs to include references to the two ASP include files created by The Website Utility (TWUSearchData_JScript.asp and TWUSearchCode_JScript.asp):</font></p>
<p><pre><<a href='mailto:%@Language="VBScript"%'>%@Language="VBScript"%</a>>
<script language="JScript" runat="Server">
var TWU_MaximumSearchResults = 20;
var TWU_DisplayPageTitles = true;
var TWU_DisplayPageDescriptions = true;
var TWU_DebugMode = false;
</script>
<!--#include file="TWUSearchData_JScript.asp"-->
<!--#include file="TWUSearchCode_JScript.asp"-->
<html>
<head>
<title>Search Results




Search Results for "<%Response.Write(TWU_GetOriginalSearchQuery())%>"

<%Response.Write(TWU_DisplaySearchResults(TWU_GetModifiedSearchQuery()))%>

The search results page can of course be customised to fit in with the existing design of your website. If you want to display the search terms the user was searching for, then use this ASP code (assuming VBScript is the default scripting language):

 <%Response.Write(TWU_GetOriginalSearchQuery())%>

To display the search results, place this ASP code where you want the search results to appear:

 <%Response.Write(TWU_DisplaySearchResults(TWU_GetModifiedSearchQuery()))%>

The search results page also defines four ASP JScript variables that can be used to change the output:

  • TWU_MaximumSearchResults Controls the maximum number of pages that will be listed in the search results. This stops users getting confused by seeing large numbers of pages in the search results.
  • TWU_DisplayPageTitles If set to true then the pages displayed in the search results will show their HTML titles as clickable links. If set to false then the URL is displayed instead. URLs are also shown if a page does not have a title. If the website does not contain accurate page titles you might have to turn this feature off.
  • TWU_DisplayPageDescriptions If set to true then the pages displayed in the search results will show their HTML Description Meta Tags as page descriptions. If set to false then page descriptions are not included in the search results. If the website does not contain accurate page descriptions you might want to turn this feature off. Turning off descriptions will also increase search performance.
  • TWU_DebugMode If set to true then debugging information is displayed (you should not need to use this).

Performance Issues

A server-side ASP search engine is obviously going to have a larger performance overhead compared to using a dedicated search solution such as Microsoft's Index Server or SQL Server's full text indexing capabilities. The size of the TWUSearchData_JScript.asp include file will depend on the number of pages in the website indexed, and also the amount of content on each page in the website. It is also dependent upon the nature of the website itself - websites with pages about similar subjects will tend to require a smaller file than a website with pages about different subjects.

To create a search facility for medium to large websites of 1000+ pages, or to allow the simultaneous searching of several websites at once, then Microsoft's Indexing Service is recommended. The Index Server Companion may also be used to extend the functionality of Indexing Services.

Download the Evaluation Version

The evaluation version of The Website Utility will allow you to determine whether the ASP Search Engines it creates are suitable for use on your own websites:

Sample Search Facilities

Purchase The Website Utility


View Entire Article

User Comments

Title: Wonder Article, very helpful   
Name: Terry Pearson
Date: 2005-05-05 12:10:31 AM
Comment:
Thank you. It was very helpful to me as a beginner to understand the search engine app. Keep up the awesome work!
Title: Mr M X   
Name: Lowcrazy
Date: 2005-04-08 7:20:18 AM
Comment:
Man this one is so helpful

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2022 ASPAlliance.com  |  Page Processed at 2022-06-24 9:21:37 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search