0

When I'm trying to set mappings of an existing mapping:

ManagedProperty managedProperty = managedProperties[ManagedPropertyName];
MappingCollection mappings = managedProperty.GetMappings();
List<CrawledProperty> allCrawledProperties = new List<CrawledProperty>();
foreach (Category category in searchSchema.AllCategories)
{
  allCrawledProperties.AddRange(category.GetAllCrawledProperties());
}

foreach (string name in this.CrawledPropertyNames)
{
  CrawledProperty crawledProperty = allCrawledProperties.Where(cp => cp.Name.Equals(name)).FirstOrDefault();
  Mapping newMapping = new Mapping();
  newMapping.CrawledPropset = crawledProperty.Propset;
  newMapping.CrawledPropertyName = crawledProperty.Name;
  newMapping.ManagedPid = managedProperty.PID;
  if (!mappings.Contains(newMapping))
  {
    mappings.Add(newMapping);
  }
}

SPSecurity.RunWithElevatedPrivileges(delegate
{
  managedProperty.SetMappings(mappings);
});

I'm getting following DatabaseException:

Microsoft.Office.Server.Search.Administration.DatabaseException: There was an internal problem connecting to or querying the database. at Microsoft.Office.Server.Search.Administration.SchemaDatabase.WrapFunction[T](String functionName, Func 1 wrappedFunction) at Microsoft.Office.Server.Search.Administration.ManagedProperty.SetMappingsInternal(MappingCollection mappings)

The managed property was created programmatically by me before.

Am I missing something?

Best regards, Hagen

0

hagenstrahl!

It happens when SharePoint Search config is wrong. This article can help you http://technet.microsoft.com/en-us/library/gg502597(v=office.15).aspx

My problem was: SP Search application pool run under farm account, but my code run under service account. When i tryed read all crawled properties, then catched DatabaseException.

I resolve problem with article above. I use accounts: spservice (for search pools, same as webApp pools), spcontent (for search crawler). After create Search service not forget add account ("spadmin", example) to administrators of service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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