2

is there any way we can map crawled properties to managed properties using CSOM using C#? i am not able to find any code samples for the same

any help would be greatly appreciated

1 Answer 1

0

You can't directly manipulate Managed Properties with CSOM. What you can do is Export working Search Settings from a site and then Import that settings XML via CSOM.

There is an example of how to do this on the SharePoint PnP repo. https://github.com/SharePoint/PnP/tree/master/Samples/Core.SearchSettingsPortability

You can use something like:

private static void ExportSearchSettings(ClientContext context, string settingsFile)
{
   SearchConfigurationPortability sconfig = new SearchConfigurationPortability(context);
   SearchObjectOwner owner = new SearchObjectOwner(context, SearchObjectLevel.SPWeb);
   ClientResult<string> configresults = sconfig.ExportSearchConfiguration(owner);
   context.ExecuteQuery();
   string results = configresults.Value;
   System.IO.File.WriteAllText(settingsFile, results);
}

private static void ImportSearchSettings(ClientContext context, string settingsFile)
{
   SearchConfigurationPortability sconfig = new SearchConfigurationPortability(context);
   SearchObjectOwner owner = new SearchObjectOwner(context, SearchObjectLevel.SPWeb);
   sconfig.ImportSearchConfiguration(owner, System.IO.File.ReadAllText(settingsFile));
   context.ExecuteQuery();            
}

From: PnP Search Customization Guidance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.