Windows Desktop Search 4.0 is a pretty cool little piece of software; it indexes a computer and allows free-text searching of file contents and properties. In fact, it replaces a lot of technologies that would have cost thousands of dollars. However, windows Desktop Search is best run on the computer where the data resides and not necessarily over the network. (Think of a corporate situation where tens or hundreds of systems are trying to index the same server... eek!)
So how do you get the results to the client desktops when you need them? Well, as Microsoft always tends to support with their products - there is a way to query WDS pragmatically.
This project really came out of a client deployment of Windows 7. Using Federated Search and the Windows 7 Start Menu Search functions, we wanted to take two data servers (with WDS installed on each) and query them. Since Windows 7 is polite enough to use OpenSearch to connect and retrieve data from search targets- there was a quick and half-day solution we could implement from end-to-end. Not only did we not have to write a search client application for the service, but we didn't have to worry about COM permissions calling the server from many low-priv client desktops.
So, how do we get the results? A lightweight WDS Web Server application could be added to the IIS server on the machine doing the indexing - and we created a small piece of code to do just that. It installs a WDSSearch web folder, which you can query using this .searchConnector-ms file.
<?xml version="1.0" encoding="UTF-8"?><searchConnectorDescription xmlns="http://schemas.microsoft.com/windows/2009/searchConnector"><description>Search WDS Server for some keywords</description><isSearchOnlyItem>true</isSearchOnlyItem><isIndexed>true</isIndexed><includeInStartMenuScope>true</includeInStartMenuScope><domain>http://mydomain.com</domain><supportsAdvancedQuerySyntax>true</supportsAdvancedQuerySyntax><templateInfo><folderType>{8FAF9629-1980-46FF-8023-9DCEAB9C3EE3}</folderType></templateInfo><locationProvider clsid="{48E277F6-4E74-4cd6-BA6F-FA4F42898223}"><propertyBag><property name="OpenSearchShortName"><![CDATA[Archived Files]]></property><property name="OpenSearchQueryTemplate"><![CDATA[http://myserver.mydomain.com/WDSSearch/Search.ashx?Search={searchTerms}&Type=File]]></property><property name="MaximumResultCount" type="uint32"><![CDATA[512]]></property></propertyBag></locationProvider></searchConnectorDescription>
We placed the file in c:\program files with a different installer, and then hooked up group policy to push the settings and make the search installable on the Start menu. However, you could put the file on the desktop and just double-click it when you want to search that location, too.
There is one other problem related to doing the indexing on the server; the file locations are relative to the server and not necessarily the client. We handle this by re-mapping file locations on the fly as results are returned. For that, in the WDSSearch\App_Data folder, we have a replacements.xml file which contains Regular Expression replacements that can be customized:
<?xml version="1.0" encoding="utf-8" ?><FSSI-FedSearch> <Configuration><Channel Title="FSSI Federated Desktop Search Source" Link="http://mydomain.net/"/><Limits MaxResults="250" /></Configuration><PathOperation><Operation Match="^[A-Za-z]:\\Management\\" Mode="Skip"/><Operation Match="^[A-Za-z]:\\Projects\\" Mode="Replace" ChangeTo="O:\"/></PathOperation></FSSI-FedSearch>
The WDSSearch code searches the PathOperation node for any Operation child nodes. It applies each to the file in question and either replaces or skips the file/location type. If it skips the file, it isn't displayed in any result RSS feed.
For a file on the server indexed as "E:\Management\Staff.XMLX', the first Operation node tells WDSSearch to eliminate that from the results set. However, anything like "E:\Projects\2001-99922-1112\Proposal.docx" will get changed on the fly to "o:\2001-99922-1112\Proposal.docx" by the Match and ChangeTo XML Attributes. Of course, the above example assumes that the clients are mapped to drive O:\. You could also use:
<Operation Match="^[A-Za-z]:\\Projects\\" Mode="Replace" ChangeTo="\\MyServer\ArchivedData\"/>
By the way, the available Modes for the Mode XML Attribute are Currently 'Skip' and 'Replace'. The Match XML attribute is a .NET Regular expression, and is passed through Regex.Replace. The ChangeTo is what the matches are replaced with.
You can even publish things over the web with this method; like:
<Operation Match="^[A-Za-z]:\\Projects\\" Mode="Replace" ChangeTo="http:\\MyServer.MyDomain.Com\PublicDownload\"/>
Just turn on directory browsing and web-share that folder ... although you will want to secure the data by ACL or some other means to protect it from anonymous activity.
You can modify the replacements.xml file at any time, and the next search request will automatically detect the file-modification time has changed and re-load the XML file and configuration.
Below is the installer for the V1 IIS site; The sample even properly passes complex search terms like AND and "PHRASE THAT MUST BE INCLUDED" and not searches like (-WORD) to the WDS query engine.
Download for Windows Desktop Search 04.00.6001.503: WDSSearchPublic.msi (414.00 kb)