Click here to Skip to main content
11,934,199 members (37,367 online)
Click here to Skip to main content
Add your own
alternative version


37 bookmarked

OmniSearch (Google Caching Engine)

, 10 Feb 2003
Rate this:
Please Sign up or sign in to vote.
OmniSearch attempts at showing a way to reduce the number of hits to the Google Web Service by caching searches.


The OmniSearch project was founded around the idea of designing a customizable search engine for seamless integration into any current website that runs the ASP.NET framework. OmniSearch can accomplish this by caching the results from the Google API and displaying the results as a manipulated XML file using XSL. This will allow for flexibility and ease of programming for the administrator.

OmniSearch will use the Google API as the backbone to the OmniSearch engine, which will do the bulk of the processing for the application. OmniSearch’s fully query-able statistics engine will collect click-through habits, from the users, for later analysis by the administrator of the site. The OmniSearch engine will serve a variety of functions including, but not limited to:

  • Maintaining a statistical record of click-throughs.
  • Caching search results from Google’s XML SOAP API.
  • Providing a Wireless WAP interface for mobile users to take advantage of OmniSearch.
  • Provide components to integrate into existing ASP.NET projects that webmasters may be running.


This project’s main goal is to get around the limitations that the Google API forces on its users, which only allows 1000 hits per day. Our team plans to get around this limitation by caching the serialized results from the Google API into an XML file. Subsequent web searches will first query the XML cache to find previous search results that will fulfill the current query of the current user. By utilizing the cache, OmniSearch will become quicker and better able to handle user search requests, the more that it is being used by the site's users.

One of the hardest things about being a website administrator is collecting useful information about users habits on your site. So to further challenge the OmniSearch team, we decided to add a click-through logging feature, that will enable administrators to view pages that may be getting high traffic load. This will also aid in decreasing the time needed to find certain pages, because the administrator will be able to tell the users such things as “The Site of the Day”, “Top 5 Sites for this Month”, and so on.

In addition to the cached search results and statistics database, OmniSearch will also support WAP interfaces for the search engine. By using ASP.NET Mobile Architecture, the OmniSearch team is able to provide a wireless interface, that will customize itself according to the wireless browser that is being used.

Using the code

The following parameters need to be setup in the web.config file, before anything will work correctly.

<!-- application specific settings -->
    <!-- Realative Location of Cache -->
    <add key="CacheLocation" value="\cache" />
    <!-- Directory Name of Website -->
    <add key="DirectoryName" value="\OmniSearch" />
    <!-- Static Location of Website -->
    <add key="WebSiteLocation" value="D:\Websites\Development\OmniSearch" />
    <!-- Proxy Settings if needed -->
    <!-- Set a host to use as an HTTP proxy. If unset, 
        GoogleSearch will also check the 
        system properties and use those values. If those 
        are also unset, HTTP requests 
        go direct with no proxy.
    <add key="ProxyHost" value="" />
    <!-- Set a port to use as an HTTP proxy. 
        Only used if proxyHost is also set. If 
        unset, port 80 is assumed to be the default.
    <add key="ProxyPort" value="" />
    <!-- Set the username required for the HTTP proxy. 
      Only used if ProxyHost is also set. -->
    <add key="ProxyUsername" value="" />
    <!-- Set the password required for the HTTP proxy. 
      Only used if ProxyHost is also set. -->
    <add key="ProxyPassword" value="" />
    <!-- Google Configuration Information -->
    <!-- Set the user key used for authorization by 
        Google SOAP server. This is a 
        mandatory attribute for all requests.
        A key can be obtained from
    <add key="GoogleKey" value="" />
    <!-- Set the maximum number of results to be returned.  
        The number must be between 1 and 10 
    <add key="GoogleMaxReturn" value="10" />
    <!-- Enable or disable the "related-queries" filter.
        Must be [True | False]
    <add key="GoogleFilter" value="False" />
    <!-- Set the restrict. 
        This allows you to restrict the search to 
        a specific document store such as 
        "Penn State", "IST" or any argument that can 
        be used in a normal Google Search.
    <add key="GoogleRestrict" value="" />
    <!-- Enable or disable SafeSearch. When SafeSearch 
        is turned on, sites and web pages 
        containing pornography and explicit sexual 
        content are blocked from search 
        results. While no filter is 100% accurate, 
        Google's filter uses advanced 
        proprietary technology that checks keywords 
        and phrases, URLs and Open Directory 
        Must be [True | False]
    <add key="GoogleSafeSearch" value="False" />
    <!-- Domain to search -->
    <add key="DomainToSearch" value="" />
    <!-- Number of days the cache will stay in memory -->
    <add key="ExpireTime" value="5" />

The following is an example of the XSL file that can be used against the serialized form of the XML cached search from Google's Web Service. This XSL file displays the search contents, just like you would see on the Google search page. In the source code this file is called searchresults.xsl.

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" 
<xsl:output method="html" version="4.0" 
   encoding="iso-8859-1" indent="yes" />
<xsl:template match="/">
    <xsl:apply-templates select="GoogleSearchResult" />
<xsl:template match="GoogleSearchResult">
    <table width="100%" border="0" cellspacing="0" 
        cellpadding="0" bgcolor="#6699cc" 
        style="padding: 5px, 5px, 5px, 5px; margin-top: 5px;" ID="Table1">
        <tr style="color:white;">
            <td aling="left">Search <b></b> for <b>
                    <xsl:value-of select="searchQuery" />
            <td align="right">Results <b>
                    <xsl:value-of select="startIndex" />
                </b> - <b>
                    <xsl:value-of select="endIndex" />
                </b> of about <b>
                    <xsl:value-of select="estimatedTotalResultsCount" />
    <table border="0" cellspacing="0" cellpadding="0" ID="Table2">
        <xsl:for-each select="resultElements/ResultElement">
                        <a style="color:blue;" 
                            <xsl:value-of select="title" />
                    <xsl:value-of select="snippet" />
                    <span style="color:green;"><xsl:value-of select="URL" />
                        - <xsl:value-of select="cachedSize" /></span>
                    <a style="color:gray;" 
                    <a style="color:gray;" 
                    Similar pages</a>
                    <br />
    <table width="100%" border="0" cellspacing="0" 
                         cellpadding="0" bgcolor="#6699cc" 
        style="padding: 5px, 5px, 5px, 5px; margin-top: 5px;" ID="Table3">
        <tr style="color:white;">
            <td align="left">
                    <a style="color:white;" 
                        « Back</a>
            <td align="right">
                    <a style="color:white;" 
                        Next »</a>

The following code is all that is needed in order to implement the OmniSearch engine in any ASP.NET webpage. It took a lot of time, but I wanted to make it simple to use, but really powerful at the same time.

protected System.Web.UI.WebControls.Xml resultsXml;      
private void Page_Load(object sender, System.EventArgs e)
    search = new SiteSearch(Request.QueryString["search"]);

    // if there is no start query then the program assumes that
    // it wants to start the search at the begining
    if (Request.QueryString["forward"] == null && 
                   Request.QueryString["back"] == null)
        start = 1;
    else if (Request.QueryString["forward"] != null && 
                   Request.QueryString["back"] ==  null) 
        start = Convert.ToInt32(Request.QueryString["forward"]) +1; 
    else if (Request.QueryString["forward"] == null && 
                   Request.QueryString["back"] != null)
        start =  Convert.ToInt32(Request.QueryString["back"]) - 
        start = 1;
    if(start <  1)
        start = 1;

    resultsXml.DocumentSource = search.DoSearch(start);

This is an example of what the ASP.NET page can look like when you put it all together. The following line of code is all you really need to implement the OmniSearch engine in any ASP.NET application that you would choose.

<asp:xml id="resultsXml" runat="server" 

Points of interest

I learned a couple of major things while implementing this code, they are listed as follows:

  • Google's Web Service is very powerful but has many limitations beyond the 1000 hits per day.
  • The use of XML serialization was very useful to the completion of this project.
  • XSL and how it can be used in .NET even if the client browser doesn't support XSL.
  • In order to get around some obstacles in naming the XML cache files, I had to use a MD5 value of the search query plus an indexing number on the end of the MD5 for the specific pages. The file will be in this format [search query (MD5 Value)].[page index].xml when it is written to the /cache directory.

One thing that needs to be done before OmniSearch can be used.

  • The caching directory /cache needs to be granted full access to [computer name]\ASPNET. This needs to be done so that OmniSearch can write the XML cache files to the directory.

I will be eventually integrating this engine into the OmniPortal project that I am also developing. More about OmniPortal can be found at Source Forge or (Shameless plug).


  • 2/10/2003 - First release.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Nick Berardi
Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralGoogle Custom Search Engine and Forms authentication Pin
Georg Kakasevski14-Jan-10 8:47
memberGeorg Kakasevski14-Jan-10 8:47 
QuestionFinal Project ? Pin
raheela17-Jan-04 6:51
memberraheela17-Jan-04 6:51 
GeneralIs this running any where to try? thx! Pin
elbo_chew19-Feb-03 10:12
memberelbo_chew19-Feb-03 10:12 
GeneralRe: Is this running any where to try? thx! Pin
Anonymous19-Feb-03 10:15
sussAnonymous19-Feb-03 10:15 
GeneralRe: Is this running any where to try? thx! Pin
elbo_chew19-Feb-03 10:25
memberelbo_chew19-Feb-03 10:25 
GeneralRe: Is this running any where to try? thx! Pin
elbo_chew19-Feb-03 10:27
memberelbo_chew19-Feb-03 10:27 
GeneralRe: Is this running any where to try? thx! Pin
Anonymous19-Feb-03 14:15
sussAnonymous19-Feb-03 14:15 
GeneralRe: Is this running any where to try? thx! Pin
Anonymous25-Oct-05 8:56
sussAnonymous25-Oct-05 8:56 
GeneralOmni Portal and IBuySpy Pin
Soliant11-Feb-03 15:00
memberSoliant11-Feb-03 15:00 
GeneralRe: Omni Portal and IBuySpy Pin
Anonymous12-Feb-03 5:51
sussAnonymous12-Feb-03 5:51 
GeneralRe: Omni Portal and IBuySpy Pin
roman_shalalalala20-Dec-06 2:11
memberroman_shalalalala20-Dec-06 2:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 11 Feb 2003
Article Copyright 2003 by Nick Berardi
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid