Doing blended search results in SharePoint–Part 2: The Custom CoreResultsWebPart Way

(Part 1: The Hackish Way)

In Part 1 I used two Search Core Results Web Parts and a bit of jQuery magic to achive the look of blended search results

This time we will create our own CoreResultsWebPart and inject the blended results into the result xml before it is transformed into html. In addition to blend in news results I decided to get some  images as well. I did this by importing a “Federated Location” for Flickr. The location definition can be found at “Flickr Search Connector for SharePoint Server, Search Server, and FAST Search for SharePoint”.

I started off by creating an empty SharePoint 2010 project in VS2010 and added a new web part.


After deploying and activating the feature I replaced the Search Core Results Web Part with my own Search Blended Core Results Web Part.


Since I use FS4SP as the search back-end remember to copy the xslt from the original web part as the default xslt is for internal SharePoint search.

By overriding the GetXPathNavigator we have full control over the result xml. The blended results are retrieved asynchronous while we get the local results from the page’s query manager on the main thread.

The blended searches have been hard coded for Bing News and Flickr, but you could very well modify the web part to include settings where you choose which federated locations to use for your blended results. In order to execute the search we create a new QueryManager object and add both search locations to it. This enables the QueryManager to execute both the news and the images search at the same time, and the results are concatenated as two channels inside the returning rss feed. The rest of the code is parsing the rss and appending it into the main xml results.

The complete code can be downloaded from my SkyDrive and includes result.xslt which is used for rendering the results. Click the icon below for the download.

Creating the xml for the blended results is fairly easy and for the images I add nodes to make the results look like they came from a SharePoint picture library in order to utilize image display already in the xslt. I have also added some markers which are used in the xslt to define the start and stop of the blended results so I can add a headline marking the blended section.
The following regular expression is used to pull out the image url from the RSS summary.

And the code to build the result xml for each item:

XSLT modification:

By using the same internal sample data as in Part 1, the result looks like this with both news and images blended in:
Right now they take up too much space for production quality layout, but that’s an exercise left to the xsl savvy out there Smile. And you probably don´t want to blend both news and images after hit number three.

And I want to thank Corey Roth for his excellent posts on how to use the QueryManager class.

This post is cross-posted from Tech and Me.

Article written by

Computer literate and search enthusiast with an interest for sharepoint, coding, and life in general :)

Leave a response

XHTML: These tags are allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

301 Moved Permanently

Moved Permanently

The document has moved here.


Comperio AS
Øvre Slottsgate 27
NO-0157 Oslo,
+47 22 33 71 00
View map


Search Provider Sverige AB
Gamla Brogatan 34
SE-11 120 Stockholm
+46 8-21 49 00
View map