|
ASP Kitchen: Classic ASP Articles: More about Searching Index Server With ASP More about Searching Index Server With ASPIntroductionA previous article in the ASP Kitchen demonstrated how ASP could be used to create a web front-end to Index Server. While the search results page demonstrated in the article contained most of what is needed to create a results page, its formatting of the search results was pretty basic, as can be seen below:
Contrast this with the search results page from my personal website below. This demonstrates what sort of formatting can be applied to the search results. If you want to see this page in action, try the search facility on my personal website.
Improving the display of column propertiesAs was described in the previous article, each search result contains a number of column properties. These contain information about each search result. In the previous article, the properties used were: FileName, doctitle, Size, Create and Characterization. As will be described below, each of these can be used to provide useful information in search results pages. Hyperlinking the search result's filenameThe FileName column property contains the search result's filename (e.g. default.htm). However, a more useful column property is vpath, which also contains the file's path as well as its filename (e.g. /financial/reports/june2002/default.htm). Once the file's path is know, it is straightforward to hyperlink the search result's URL using something like the following: Const SERVER_URL = "http://www.brettb.com"Response.write "<b>URL:</b> <a href=""" & SERVER_URL & oRS("vpath") & """>" & SERVER_URL & oRS("vpath") & "</a><br>" A common convention when presenting search results is to hyperlink the document's name to its URL. Index Server uses the doctitle column property to store the document's name): Const SERVER_URL = "http://www.brettb.com"Response.write "<b>URL:</b> <a href=""" & SERVER_URL & oRS("vpath") & """>" & oRS("doctitle") & "</a><br>" Displaying the search result's file sizeThe Size column property contains the size of the file in bytes. A small formula can be used to display the file's size in Kilobytes, which is often a better unit of measure for file sizes: Response.write "<b>Size:</b> " & Round(CInt(oRS("Size"))/1024, 1) & "K <br>" Displaying the document creation and modification datesThe creation and modification date and time for files are contained within the Create and Write column properties, respectively. These can be formatted to display a more user friendly date by use of the FormatDateTime VBScript function as shown below: Response.write "<b>Create:</b> " & FormatDateTime(oRS("Create"), 1) & "<br>"Response.write "<b>Write:</b> " & FormatDateTime(oRS("Write"), 1) & "<br>" Further document propertiesA number of other document properties may be of interest, such as HitCount (the number of words matching the query that were found in the file), and Rank (how closely the file matched the query). A more detailed description of the Rank column property is in the following section. A complete listing of column properties is available here (it is also available in the IIS 4.0 documentation). Many properties are only of relevence if Microsoft Office documents are being indexed. Remember that if you wish to use any additional columns then they must be listed in the Columns property of the Index Server Query COM component, e.g. oQuery.Columns = "DocAuthor, vpath, doctitle, FileName, Path, Write, Size, Rank, Create, Characterization, HitCount" Displaying a file's rankThe Rank column property is used as a measure of how closely a document returned by Index Server matched the search query. Rank ranges between 0 and 1000, with 1000 being the closest match. The calculation of rank is fairly complex, but a good explanation is available. To summarise, rank depends on the number of times the query terms appear in the document, as well as the number of times the query terms appear in the Index Server catalog.
In the search catalog on my own personal site, searches for "ASP" will return results with a low rank, because that word appears frequently (since I am an ASP developer and have lots of pages about ASP). By contrast, searches for "tomato" will return a high rank for the page about my biotechnology career, since it is the only page to contain numerous references to tomatoes. In a search results page, rank can be displayed as a percentage by simply dividing the Rank by 10: Response.write "<b>Rank:</b> " & CInt(oRS("Rank")/10) & "%<br>"Alternatively, it can be displayed graphically. There are a number of ways of achieving this. On my personal search page, the results are accompanied by a graphic showing from 0 to 10 filled bars, according to the rank. So a document matching with a ranking of between 700 and 800 will get 8 bars, and therefore an 80% ranking. Obviously the number of filled bars can only give an approximate ranking, but it is there as a visual aid so an accurate ranking is not important. If you want to use the method I use, the code is below. The code should of course be executed for each page in the search results. iCurrentRanking = oRS("Rank") 'Retrieve the search ranking for this particular search result The appropriate rank image is then inserted using the following ASP: <img src="images/<%=iRanking%>bars.png" alt="<%=sCurrentRankingAltTag%>" width="80" height="17"> Note that the images are in the images sub-folder, and are named from 1bars.png to 10bars.png. Examples are shown below:
Futher Index Server goodiesNeed to figure out how to do other things with Index Server? to me and I'll add them to the Index Server section of the ASP Kitchen! Code samples and working ASP pages
Further reading
Useful Development Tools
Author detailsBrett Burridge has worked as a web developer since 1997 and has developed web applications for a range of corporations, start up busiensses and educational establishments. Brett is presently employed as an Internet developer and technical writer through his own company, Winnersh Triangle Web Solutions Limited. The company produces a number of innovative products, including a range of software documentation tools, which include the ASP Documentation Tool, the .NET Documentation Tool for VB.NET and C#, and the SQL Server Documentation Tool. Other products include The Website Utility, which functions as a website error checker, search engine optimizer and ASP/ASP.NET search engine builder application. As well as the ASPAlliance, Brett has written articles for Ariadne.ac.uk, ASPToday, the software documentation portal www.softwaredocumentation.info, and has contributed recipes to the ASP.NET Developer's Cookbook. links Outside web development, Brett is interested in travelling (here are my travel logs from New York, Hong Kong and Tokyo), digital photography (here's my photo gallery), tropical fishkeeping and collecting contemporary works of art by artists such as Doug Hyde. Contact Brett by emailing Article history"More about Searching Index Server With ASP" published on ASPAlliance.com on 4 October 2001. ASP Kitchen: Classic ASP Articles: More about Searching Index Server With ASP |
|
|||||||||||||||||||||||||||||||||||
| © page content copyright Brett Burridge 1998 - 2009. | ||||||||||||||||||||||||||||||||||||