public string PutIndex(string name, IndexDefinition definition)
        {
            switch (IndexDefinitionStorage.FindIndexCreationOptionsOptions(name, definition))
            {
            case IndexCreationOptions.Noop:
                return(name);

            case IndexCreationOptions.Update:
                // ensure that the code can compile
                new DynamicViewCompiler(name, definition).GenerateInstance();
                DeleteIndex(name);
                break;
            }
            IndexDefinitionStorage.AddIndex(name, definition);
            IndexStorage.CreateIndexImplementation(name, definition);
            TransactionalStorage.Batch(actions =>
            {
                actions.AddIndex(name);
                var firstAndLast = actions.FirstAndLastDocumentIds();
                if (firstAndLast.Item1 != 0 && firstAndLast.Item2 != 0)
                {
                    for (var i = firstAndLast.Item1; i <= firstAndLast.Item2; i += Configuration.IndexingBatchSize)
                    {
                        actions.AddTask(new IndexDocumentRangeTask
                        {
                            FromId = i,
                            ToId   = Math.Min(i + Configuration.IndexingBatchSize, firstAndLast.Item2),
                            Index  = name
                        });
                    }
                }
                workContext.ShouldNotifyAboutWork();
            });
            return(name);
        }
        public string PutIndex(string name, IndexDefinition definition)
        {
            switch (IndexDefinitionStorage.FindIndexCreationOptionsOptions(name, definition))
            {
            case IndexCreationOptions.Noop:
                return(name);

            case IndexCreationOptions.Update:
                // ensure that the code can compile
                new DynamicViewCompiler(name, definition, Extensions).GenerateInstance();
                DeleteIndex(name);
                break;
            }
            IndexDefinitionStorage.AddIndex(name, definition);
            IndexStorage.CreateIndexImplementation(name, definition);
            TransactionalStorage.Batch(actions => AddIndexAndEnqueueIndexingTasks(actions, name));
            return(name);
        }