Jim O'Neil
Technology Evangelist
Join App Builder
Keep The Cash! Earn $100 for every app you publish! Let me know how I can help!
It’s a stuffy-sounding name, but I’m finding the Federated Search capability in Windows 7 rather cool, and starting the see all kinds of uses of it to improve my own productivity.
Federated Search leverages the OpenSearch API and the common syndication formats of RSS and Atom to enable searching of enterprise and internet sources directly from Windows Explorer, with the results displayed just as if they were files on the local file system.
The premise is rather straightforward and is captured by the diagram below (with explanation following).
http://channel9.msdn.com/Search/feed/rss/?Term={searchTerms}
{searchTerms}
<title>
<description>
Now comes the fun part. You actually have a bit of control over what information is displayed and where. One area you can customize is the Content View (the area showing information for each search result). That view can display up to seven fields, placed as follows:
Obviously, there’s a default placement and assignment of information from the feed to the various slots, but that can be overridden either in the search results (via additional tags embedded the Atom or RSS markup) or, conveniently, in the client .osdx file. If you open the .osdx file in Notepad or any other text editor, you can get a better idea of how things work.
Now, remember that the feed that comes back is the result of the URL referenced in the .osdx file, so there may be other information of interest in that feed that you want to surface within Windows Explorer. Three things that stand out to me from the RSS markup above are the number of views, the date of publication, and the link to the associated blog post, so let’s modify the output to include those.
The key to doing this is realizing that each slot in the layout can be occupied by a Shell property associated with the search item result. By coupling a known shell property with a specific data item in the RSS feed, you can populate the search result view as you’d like to see it. There is a default mapping of items in the RSS feed to shell properties which drives how the search results look now; here’s a few of them:
But I’m looking to get a display something like the following, where I’ve highlighted the new items. Note, I also got rid of the size and tags fields.
What I need to do first is map the property values in the RSS to some Shell properties; the table below summarizes my choices.
Additional XML added to the .osdx file captures this mapping:
The ResultsProcessing tag (unclosed in the snippet above) envelops tags to provide a customization of the base RSS results. That’s followed by a number of PropertyMap tags. Each of those names a Source property in the RSS (possibly qualified by a sourceNamespaceURI) and maps it to a Shell property, the name of which is the attribute of the child Property tag.
You might ask how I knew which Shell properties to use. While I couldn’t find a definitive resource, I selected these based on their relative correlation to what I was trying to display. Some Shell properties are used by the results processing step itself (like System.Item.PathDisplay) so you can’t use them.
Now that I have the source data mapped the Shell properties, I need to specify how I want them placed in the user interface. Enter another bit of XML:
The PropertyDefaultValues tag (which is another child node of ResultsProcessing)wraps the ContentViewModeForSearch property, indicating the intention to adjust the layout of the seven items in the search results line. You can adjust the layout in the details at the bottom of Windows Explorer as well as the tooltip, but that’s an exercise left to the reader!
The value for the property is the literal string “prop:”, followed by a semi-colon delimited list of Shell properties ordered according the field map above. You should always have seven Shell properties in this list; if you want to leave a slot empty, specify the property System.LayoutPattern.PlaceHolder, versus leaving it blank. Parsing the string in the snippet above and overlaying it on the ‘map’ results in something like this:
By default, the values will be preceded with a label that’s associated with it by the handler for that Shell item. If you don’t want to see the label, preface the property with the tilde character. Lastly, be sure there is no white space in this string, including preceding the “prop:” literal, or you’ll results will not display correctly (if at all).
Hopefully, if you wanted to follow along, you were successful in your venture. I’ve also uploaded the final .osdx file to this blog post in case you want to start there and deconstruct it.
There’s definitely a lot going on under the covers here, and mucking with the base XML is error-prone (for me at least!). For more detailed documentation to help fill in the gaps, check out:
Federated Search in Windows 7 (MSDN) Creating an Open Search Description File SQL Server Connector Example
Federated Search in Windows 7 (MSDN)
Creating an Open Search Description File
SQL Server Connector Example
Be aware too, that we really just discussed the client part. You can write your own WCF services that return Atom or RSS to provide a search over just about anything you like. You can even write a local provider that implements IOpenSearchSource. Just make sure you follow the OpenSearch guidelines and best practices as much as possible to ensure a smooth integration into the Windows Explorer experience.
Tank you for a well written and very useful article! Properly used federated search can be such a big improvement over existing GUI:s
Thnx!
Thanks for the kind words Joakim. I agree, it's kind of an undiscovered gem. I'm finding myself writing some of these connectors to streamline common searches... rather than open a website, enter info, etc., I can Windows+E and search. And I almost always have Windows explorer instance on my desktop.
How developer is going to implement Federated search in semantic platform?
Please help me out with this questions.Please email me in this account# mohammad.tanvir@gmail.com if possible. I will be so greatfullllllllllll