Import SharePoint Site Search Configuration using Client Object Model C#

In my previous post,, I had demonstrated how to export the Search Configuration of a SharePoint site.  Here, I will show how to import an exported search configuration.

To import the Search Configuration, we have to use the following namespace

using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Search.Administration; 
using Microsoft.SharePoint.Client.Search.Portability; 

In the following code, the string variable, searchConfiguration, holds the search configuration

ClientContext ctx = new ClientContext(weburl);
ctx.Credentials = new SharePointOnlineCredentials(userName, passWord);
SearchConfigurationPortability searchConfigurationPortability =

new SearchConfigurationPortability(ctx);
SearchObjectOwner searchObjectOwner = new SearchObjectOwner(ctx, SearchObjectLevel.SPWeb);

searchConfigurationPortability.ImportSearchConfiguration(searchObjectOwner, searchConfiguration);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s