SharePoint 2013 Search: Exporting and Importing Search Configuration Settings

Tags: SharePoint, Search, Admin, Configuration, PowerShell

Search in SharePoint 2013 is now front and center and is the first place you should look to add functionality to SharePoint in a configurable way without resorting to custom code. From the Content Search Web Part, Site Collection and Web level control over the Search schema, automatic Managed Properties, to Cross-site publishing, Search is huge in SharePoint 2013 and it makes the configuration over customization decision very easy. One caveat to mention, though, is that the content from the search index is not real time. A crawl has to occur to discover or update content sources, content processing has to apply any data cleansing or enrichment, and finally the index is populated and ready to serve content to user queries or queries issued by the Search components mentioned above. So, whether you have incremental crawling with Continuous Crawl enabled or not, there will be a lag from when new or updated content is added to the environment and when it will be available for Search consumption.

The near-real-time aspects of SharePoint 2013 Search will only exclude Search as a viable option for extending SharePoint in a limited set of solutions. For all most every other use case, Search is the way to go!
After you have Search configured in your Site Collection the way you want, you may need to move the configuration to another environment. Chances are that you will also have Display Templates and other design artifacts that you need to migrate to the target environment. In cases like these, the Design Manager “Create Design Package” step will probably be the option you choose to export your search settings, provided you check the “Include Search Configuration in this package” box:
 
However, if you just want to export your Search Schema settings because you’ve stored your Display Templates and other design assets in a source control system and you’ll apply them manually to another environment, you can use the following PowerShell to export and import your search configuration settings in SharePoint 2013:
 

Export

 
$site = Get-SPSite http://<site>

 

$searchConfig = New-Object Microsoft.Office.Server.Search.Portability.SearchConfigurationPortability($site)
$owner = New-Object Microsoft.Office.Server.Search.Administration.SearchObjectOwner([Microsoft.Office.Server.Search.Administration.SearchObjectLevel]::SPWeb, $site.OpenWeb())

 

$searchConfig.ExportSearchConfiguration($owner) | Out-File -FilePath <filePath>

 

 

Import

 
$site = Get-SPSite http://<site>
$searchConfig = New-Object Microsoft.Office.Server.Search.Portability.SearchConfigurationPortability($site)
$owner = New-Object Microsoft.Office.Server.Search.Administration.SearchObjectOwner([Microsoft.Office.Server.Search.Administration.SearchObjectLevel]::SPWeb, $site.OpenWeb())
$configuration = Get-Content <filePath>
$searchConfig.ImportSearchConfiguration($owner, $configuration)
 

I hope these search configuration export and import routines are helpful and get you on-track to configuring fantastic search-based experiences in SharePoint 2013. Custom code is great, but when you can configure powerful out-of-the-box features like these to achieve custom-level functionality, it will reduce upgrade and migration headaches in the future and free you to focus on providing business value from your SharePoint 2013 investment.

 

No Comments

Add a Comment