Hi,
I need help with this method to create mapping between managed property and crawled property.
public static void CreateMapping(SPWeb web, SearchAdmin.SearchObjectLevel level, string categoryName,
string managedPropertyName, string crawledPropertyName)
{
// Get search owner (search scope)
SearchAdmin.SearchObjectOwner searchOwner = new SearchAdmin.SearchObjectOwner(level, web);
// Get search service app proxy
SearchAdmin.SearchServiceApplicationProxy searchProxy = GetSearchProxy(web);
if (searchProxy == null)
{
return;
}
// Get managed property
SearchAdmin.ManagedPropertyInfo managedProperty = searchProxy.GetManagedProperty(managedPropertyName, searchOwner);
SearchAdmin.ManagedProperty mp = new SearchAdmin.ManagedProperty();
// If managed property exists
if (managedProperty != null)
{
//SearchAdmin.SearchObjectOwner SsaOwner = new SearchAdmin.SearchObjectOwner(SearchAdmin.SearchObjectLevel.Ssa, web);
// Get crawled property by name
System.Collections.Generic.List<SearchAdmin.CrawledPropertyInfo> crawledProperties = searchProxy.GetAllCrawledProperties(crawledPropertyName, categoryName, 0, searchOwner);
//SearchAdmin.CrawledPropertyInfo crawledProperty = searchProxy.GetCrawledProperty(categoryGuid, crawledPropertyName, 0, false, searchOwner);
// If crawled property exists
if (crawledProperties.Count > 0)
{
// Set mapped crawled properties
managedProperty.MappedCrawledProperties = new System.Collections.Generic.List<SearchAdmin.CrawledPropertyInfo>();
managedProperty.MappedCrawledProperties.Add(crawledProperties[0]);
// Update managed property
searchProxy.UpdateManagedProperty(managedProperty, searchOwner);
}
}
}
Any suggestion?
Thanks!
No problem with the first “return”.
I have already traced all the code and seems to be work from beginning to the finish, but the changes don’t apply to the search schema.
Well, maybe you’ve got the first “return”, then?
I’d recommend to add more tracing/logging to the method to understand what exactly the flow during the execution.
Hello Ivan,
Would it be possible to reformat post as it is quite challenging to read.
Next, what’s wrong with the current implementation? Does it work? Does it throw exception? What’s going on with it?