Integrate Windows Desktop Search 2.x with Web Search






4.18/5 (2 votes)
An article on integrating Microsoft's Windows Desktop Search engine with Web search on an intranet

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:
-
public DataTable ExecuteQuery(string query, int maximumNumberOfResults, string columns, string sortByColumn, string restriction)
-
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:
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