Create a Search Property:
First, we need to know how to create a search property before migrating it.
First, we need to know how to create a search property before migrating it.
- We should log into the SharePoint Admin Center.
- Click Search from the left menu.

- Select “Manage Search Schema”

- Select “New Managed Property”.

- Then give the Property Name, Description, Type of the property and select the Searchable, Retrievable checkbox.
- In the mapping to crawled property section, select “Add a Mapping” to choose the property or column
Migrating Search Crawl Property:
After creating the property, create a windows application and add “Microsoft.SharePointOnline.CSOM” Nuget package to the solution. We have to perform Export and Import operation to perform the migration. For exporting the search managed property use the below code snippet.
private static string exportSearchSettings(ClientContext clientContext) {
SearchConfigurationPortability searchConfiguration = null;
SearchObjectOwner searchObjectOwner = null;
ClientResult < string > configResults = null;
string stringresult = string.Empty;
try {
searchConfiguration = new SearchConfigurationPortability(clientContext);
searchObjectOwner = new SearchObjectOwner(clientContext, SearchObjectLevel.SPSiteSubscription);
configResults = searchConfiguration.ExportSearchConfiguration(searchObjectOwner);
clientContext.ExecuteQuery();
if (configResults.Value != null) stringresult = configResults.Value;
} catch (Exception) {
throw;
}
return stringresult;
}
From the above code, we will be getting an xml string which can be imported to another site. After the above code execution, make sure that you’re storing the content somewhere to reuse it. I am saving the document as a file inside the application as “searchConfiguration.xml”
After storing it, use the below code to migrate the configurations to a new tenant.
private static void importSearchSettings(ClientContext clientContext) {
SearchConfigurationPortability searchConfiguration = null;
SearchObjectOwner searchObjectOwner = null;
string location = string.Empty, directory = string.Empty;
try {
location = Assembly.GetExecutingAssembly().Location;
directory = Path.GetDirectoryName(location);
searchConfigurationString = System.IO.File.ReadAllText(directory + "/searchConfiguration.xml");
searchConfiguration = new SearchConfigurationPortability(clientContext);
searchObjectOwner = new SearchObjectOwner(clientContext, SearchObjectLevel.SPSiteSubscription);
searchConfiguration.ImportSearchConfiguration(searchObjectOwner, searchConfigurationString);
clientContext.ExecuteQuery();
} catch (Exception) {
throw;
}
}
Source: