From 79a0ae86e8372ed7f218850eb8973ccbf90905e9 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 26 Aug 2015 14:42:18 -0700 Subject: [PATCH] Create index command should not delete existing index --- .../Orchard.Indexing/Commands/IndexingCommands.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Indexing/Commands/IndexingCommands.cs b/src/Orchard.Web/Modules/Orchard.Indexing/Commands/IndexingCommands.cs index d6ecbcd0b..de99edee1 100644 --- a/src/Orchard.Web/Modules/Orchard.Indexing/Commands/IndexingCommands.cs +++ b/src/Orchard.Web/Modules/Orchard.Indexing/Commands/IndexingCommands.cs @@ -47,8 +47,19 @@ namespace Orchard.Indexing.Commands { Context.Output.WriteLine(T("Invalid index name.")); } else { - _indexManager.GetSearchIndexProvider().CreateIndex(index); - Context.Output.WriteLine(T("New index has been created successfully.")); + var indexProvider = _indexManager.GetSearchIndexProvider(); + if(indexProvider == null) { + Context.Output.WriteLine(T("New indexing service was found. Please enable a module like Lucene.")); + } + else { + if (indexProvider.Exists(index)) { + Context.Output.WriteLine(T("The specified index already exists.")); + } + else { + _indexManager.GetSearchIndexProvider().CreateIndex(index); + Context.Output.WriteLine(T("New index has been created successfully.")); + } + } } }