SharePoint 2013: Federated Search Deep Dive – Twitter

27 Nov
November 27, 2012

SharePoint Search Federation is a really underrated feature if you ask me. You can greatly improve your company’s knowledge management and create a single point of entry to all kind of data. Federation comes into play when you can not crawl the data source (too big or too complex).

With SharePoint 2013 and the very cool query templates you have literally thousand of options (to be honest you had them before but with XSLT its not that much fun) to enhance your search results.

Real Time Twitter Search

Lets do a quick example – how about adding Twitter to your search results and style it a bit?

First off, go to Central Admin and click on your with PowerShell provisioned Search Service Application. On the left menu you can see an entry “Result Sources” with 16 default sources defined by SharePoint, compared to SharePoint 2010 that is 4 times more! Most of the SharePoint sources can not be edited but they give you a clue what the intention of this is.

Step 1: Create the federation

If you want to create a search federation you simply need the OpenSearch link. For the twitter example its http://search.twitter.com/search.atom?q={searchTerms}.

Friendly reminder: Your server needs connection to the internet, at least to that site in order to work…

Step 2: Upload a new page layout

When you edit a search page you might notice that there are only two page layouts available, either you go for two columns and that is not that optimal for “side queries”. Or you change it to Web Part page and have the quick launch on the left side. Best chance to try the new design manager and create a 3 column page layout – too many steps for this article, that’s why you can download my hacked version here. Just drop the file SearchWithFederated (right click and save as!) to \\sharepoint2013\_catalogs\masterpage\ (replace sharepoint2013 with the hostname of your server or drop the file to the 15’ folder) – SharePoint 2013 will handle all the rest <— SO COOL!!!

After uploading the page layout, go to site settings of the search center and click on “Page Layouts and Site Templates” and add “SearchWithFederated” to the allowed page layouts:

SharePoint 2013 - allowed page layouts

Then create a page and e.g. call it social.aspx with the new page layout “SearchWithFederated”. The page should look like this now (except that you don’t have the cool logo!):

SharePoint 2013 - 3 colum page layout

Step 3: Add an additional search Web Part to the new zone

In SharePoint 2010 there was a “federated search Web Part” – its gone, you don’t need it anymore. You could do cool stuff with it, at Alegri we have a federation to Microsoft Dynamic where the employees skills and certificates and stuff are managed, on the screenshot you can see it on the right:

Federated search in SharePoint 2010

With SharePoint 2013 they built a lot of new search Web Parts and broke with a lot of old stuff – shiny new world! Okay back to the example, just add:

  1. Refiner Web Part to zone 1
  2. Search result Web Part to zone 2
  3. Search navigation Web Part to zone 2
  4. Search box Web Part to zone 2
  5. Search result Web Part to zone 3

SP2013 Federated Search Column

Step 4: Configure everything

Okay, lets start with the search box, that took me a while to notice that you change the connection here:

  1. Send Queries to Web Parts
    • Search results [1] (check)
    • Search results [2] (check)

Now edit Search Results [2]:

  1. Click on change query (cool new wizard, love it!)
    • Basics
      • Select a query: Twitter
      • Number of results per page: 5
      • Show advanced link: (uncheck)
      • Show result count: (uncheck)
      • Show paging: (uncheck)
      • Show preferences link: (uncheck)
    • Settings
      • Loading Behavior: Async option (this loads the results after the main results in zone 2 appears and doesn’t wait on the twitter search service)

Step 5: First results

ooookay… very cool stuff:

sp2013_federatedsearch2

You can click on the results and get redirected to twitter.

Step 6: Adjust the Display Template

So what’s next, we got it working right? Yepp, but how about the author and the date of the tweet? Let’s tackle this with the awesome new display templates – too many steps and it took me a while to figure it out (author is in the xml), just download the file Item_twitter (right click and save as!) and upload it to \\sharepoint13\_catalogs\masterpage\Display Templates\Search (again, replace the hostname)

One thing that really helped me creating the display template was the super debugger in chrome. Just add “debugger;” in the JavaScript part of the template, hit F12 in Chrome to open up the Developer Tools – and you can debug the display template and context object (just hover over it or use the console) – SWEET!

sp2013_DisplayTemplate_debugger

After uploading the display template, edit the page and set the Item Display Template to “Twitter”. The setting is in the Display Template section of the result Web Part.

Final result

And here comes the very last screenshot of this very long blog post – my longest so far!

sp2013_federatedsearch_final

Feedback?

Much appreciated in the comments!

Max Melcher

Maximilian Melcher (MCITP, MCPD) is a Managing Consultant for Alegri International Services in Munich, Germany. Max is a specialist in SharePoint technologies focused on search, social computing, web content management and collaboration.
Max has led SharePoint implementations for Dax 30 companies since 2009.

Max’s free time is spent on twitter mostly with a good coffee in his hands.
Tags:
4 replies
  1. Christian Heindel says:

    Nice one. Thanks.

    Btw.: I did sth. similar with WordPress and SP2010.

    Reply
  2. spadmin says:

    Thanks ..

    Reply
  3. sandra says:

    thanks max that is great. can you give me some hints as to how i could setup a result source to a Sharepoint 2010 index from a Sharepoint 2013 search result source? i cant find anywhere that tells me how to do this!
    Sandra

    Reply

Trackbacks & Pingbacks

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <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="">