Posted on:
Categories: SharePoint;CodePlex
Description:

While working on a client solution I ran into the need to configure the search box drop down for a few site collections. They needed a custom Result Source added, as well as have the Conversations Result Source removed.

 

Back in SharePoint 2010, this was a rather easy exercise, you just had to connect your site collection to your default search center and update the site collection search settings to display the scopes drop down, and your entire site collection would take on those settings.

 

With SharePoint 2013 I ran into some issues with this. You can connect your site collection to a search center as before, but then you still had to configure the search navigation manually on a per site basis (I'm not going to go into too much detail on this as there's a lot of articles about this now). After playing around with the search settings for a while, it started to look like there's a bug in the search settings inheritance as sub-sites were not inheriting the search navigation from the root site of the site collection. As well, once you customized the search navigation on the site, you lost the contextual "Search this site" functionality in the search box. So after a bit more research on the Internet, and a half dozen blogs later I had confirmation enough that there's some issues with configuring search navigation for a whole site collection.

 

So this presented me with two issues:

 
  • I needed an easy way to manage the search navigation on a site collection basis
  • As well, I still needed to maintain the "Search this site" contextual search
 

Some of the suggestions out there were to create a PowerShell script to configure the search navigation settings, which are valid, but that solution wouldn't allow for easy configuration for the SharePoint administrators moving forward. So to take it a bit further I decided to create a timer job that would synchronize the search navigation from a search center to specified site collections. This would simplify the management of the search navigation, without having to execute scripts every time you wanted to make a change.

 

So to allow for some more flexibility I've added in support for the following configuration settings:

 
  • Web Application (You can configure the timer job separately for each web application if you wish)
  • Search Center URL (The URL to the Search Center you wish to use for your search settings)
  • Site Collections to Update (You can specify a URL per line for all the site collections that you wish to inherit the search center's seach navigation) - Or check the Sychronize Search Navigation to all Site Collections check box
  • Sites to exclude (If you have any sites that you don't want configured by the timer job you can specify one URL per line here)
  • Include This Site Contextual Search (This allows you to still keep a contextual "Search this site" option. By default this will be placed last)
  • Make This Site Contextual Search First Option in Search Drop Down (This will make sure the "Search this site" is the first item in the search drop down, and therefore the default selected search)
 

So, how to install the timer job:

 
  • You can download the WSP from the CodePlex link at the bottom, or you can grab the source code if you wish to customize further and package your own WSP
  • Add and install the WSP to your SharePoint 2013 farm
  • In Central Administration enable the "Softlanding SharePoint 2013 Search Navigation Sync Timer Job" feature for the Web Application(s) you wish to synchronize Search Navigation Settings on
    Web Application Features
 

To configure the Timer Job:

 
  • Navigate to the "Configure Search Navigation Synchronization Timer Job" page (Go to Central Admin -> General Application Settings -> Configure Search Navigation Synchronization Timer Job
    General Application Settings Page
  • Select the "Web Application" you wish to configure the timer job for (Note: The "Softlanding SharePoint 2013 Search Navigation Sync Timer Job" feature needs to be activated for this web application)
  • Specify the "Search Center URL" you wish to inherit the Search Navigation settings from
  • Specify the "Site Collections to Update" URLs (one per line) you wish to have their search navigation settings configured by the timer job, or else check the
  • Specify the "Sites to exclude" URLs (one per line) that you wish to NOT have their search navigation settings configured by the timer job
  • Configure "Include This Site Contextual Search" and "Make This Site Contextual Search First Option in Search Drop Down" options
  • Click the Apply button
    Search Navigation Sync Timer Job Config Page
 

Note: The default schedule for the Softlanding - Search Navigation Synchronization Timer Job is hourly, to modify this schedule:

  • Go to Central Admin -> Monitoring -> Review job definitions
  • Select "Softlanding - Search Navigation Synchronization Timer Job" timer job in the Job Definitions list
  • Make your scheduling changes and click the OK button

Now the timer job will run hourly (or on whatever schedule that you configured it for) and will update all the sites in each site collection as you have configured.

Some other implementation notes that you might want to be aware of:

  • The timer job will always run on the specified schedule but it won't update the search navigation settings on all the sites unless:
    • The search navigation settings have been updated on the search center since the last time the timer job ran,
    • or any of the timer job settings have been updated since the last time the timer job ran (excluding schedule settings)
  • The site's search center is also set to the timer job's Search Center URL when it runs as well.

Hopefully as SharePoint 2013 matures and via a future CU, the search configuration will start to work more intuitively and that inheritance of search settings will work properly, for now this solution will work for most scenarios I have ran into so far.

Feel free to download the source code and let me know what you think or if you feel like adding additional functionality that'd be great. For the moment I won't be adding additional functionality to the timer job but I can see in the future the possible need for more granular control on how search settings are synchronized to other site collections.

To download this solution from CodePlex go here: https://slsearchnavsync.codeplex.com/

Updates (Oct 4, 2013):

  • Added new coonfiguration option for synchronizing to all site collections
  • Removed implementation note
  • Replaced screen shot of timer job configuration page