public string PutIndex(string name, IndexDefinition definition)
{
definition.Name = name = IndexDefinitionStorage.FixupIndexName(name);
definition.RemoveDefaultValues();
switch (IndexDefinitionStorage.FindIndexCreationOptions(definition))
{
case IndexCreationOptions.Noop:
return name;
case IndexCreationOptions.Update:
// ensure that the code can compile
new DynamicViewCompiler(name, definition, Extensions, IndexDefinitionStorage.IndexDefinitionsPath, Configuration).GenerateInstance();
DeleteIndex(name);
break;
}
IndexDefinitionStorage.AddIndex(definition);
IndexStorage.CreateIndexImplementation(definition);
TransactionalStorage.Batch(actions =>
{
actions.Indexing.AddIndex(name, definition.IsMapReduce);
workContext.ShouldNotifyAboutWork();
});
return name;
}