Click here to Skip to main content
15,867,568 members
Articles / Programming Languages / XML
Article

Integrate Windows Desktop Search 2.x with Web Search

Rate me:
Please Sign up or sign in to vote.
4.18/5 (2 votes)
3 Dec 2006CPOL2 min read 29.8K   894   11   5
An article on integrating Microsoft's Windows Desktop Search engine with Web search on an intranet
Sample Image - WdsIntegration.jpg

Introduction

Companies often provide an intranet for employees to share information and communicate. A good intranet will provide some level of search capability to allow users to find what they need on the intranet quickly and easily. In many instances, however, the bulk of content within an organisation is not stored in or attached to a formal intranet. It is stored in individual email archives, on hard drives or in shared stores such as NAS or SAN. Applications such as Google Desktop and Windows Desktop Search index this hidden content to make discovery easier across this unmanaged content.

However, this now presents a user two (or more) search experiences. Desktop search can begin to undermine the company's intranet strategy by becoming a user's first port of call when trying to find information. This is the issue that I have tried to address by fully integrating an existing Web-based intranet search capability and desktop search.

Windows Desktop Search already easily allows an intranet search button to be added to the list of available search locations. This article focuses instead on the reverse scenario - integrating desktop search results into the intranet search page. This is modelled off the Google Desktop experience. If you have Google Desktop installed and you search at google.com, the first set of results display are 'results from your desktop' followed by results from the Internet. This makes google.com the focus for a user trying to find both local content as well as Internet content.

Background

The solution presented here builds on the APIs and ideas provided here.

Using the Code

The file DesktopSearch.cs contains one class called DesktopSearcher. The two main functions are:

  1. C#
    public DataTable ExecuteQuery(string query, int maximumNumberOfResults, 
        string columns, string sortByColumn, string restriction)
  2. C#
    public string ExecuteQueryXml(string query, int maximumNumberOfResults, 
        string columns, string sortByColumn, string restriction) 

Both take the same parameters (fairly self explanatory), the only difference being the format of the results. For the purposes outlined above, the XML result format is most useful.

Within the intranet search page, a simple JavaScript call to this component onload allows the search page to retrieve local results from the user's locally installed desktop search, use an XSL to transform the results into XHTML and insert the results into the overall result set.

From the attached example, the JavaScript required would be:

C#
function searchDesktop(queryIn)
{
    var query = queryIn;
    var cols = "Rank, DocTitle, DocAuthor, PrimaryDate, 
        PerceivedType, DisplayFolder, Url, FolderName, Store";
    var sortBy = "Rank DESC";
    var where = null;
    
    var searcher = new ActiveXObject("DesktopSearch.DesktopSearcher");
    var searchResult = "failure";
    searchResult = searcher.ExecuteQueryXml(query, 15, cols, sortBy, where);
    
    var resultsDiv = document.getElementById('DesktopSearchResults');
    var resultsDivRaw = document.getElementById('DesktopSearchResultsRaw');
    resultsDivRaw.value = searchResult;
    
    var xml = new ActiveXObject("Microsoft.XMLDOM");
    xml.async = false;

    xml.loadXML(searchResult);

    // Load XSL
    var xsl = new ActiveXObject("Microsoft.XMLDOM");
    xsl.async = false;
    xsl.load("desktop.xsl");
    
    resultsDiv.innerHTML = xml.transformNode(xsl);
    resultsDivRaw.value = searchResult;
}

Issues

  • At the moment, URLs for results returned from Outlook are not reliable when output as <a> links.
  • As the solution relies on ActiveX, this is an Internet Explorer solution only.
  • Also, the zone that serves up the DLL must be trusted to avoid an Internet Explorer warning dialog.

History

  • 3rd December, 2006: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
General??? Does not work Pin
laneh200613-Dec-06 9:19
laneh200613-Dec-06 9:19 
QuestionRe: ??? Does not work Pin
laneh200614-Dec-06 4:33
laneh200614-Dec-06 4:33 

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.