diff --git a/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchBaseIndex.cs b/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchBaseIndex.cs index 121089f..dbaeee2 100644 --- a/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchBaseIndex.cs +++ b/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchBaseIndex.cs @@ -17,7 +17,7 @@ public class ElasticSearchBaseIndex : BaseIndexProvider, IDisposable { public readonly ElasticSearchConfig _connectionConfiguration; private bool isReindexing = false; - + private bool _isUmbraco = false; public readonly Lazy _client; private ElasticClient _indexer; private static readonly object ExistsLocker = new object(); @@ -44,12 +44,12 @@ public ElasticSearchBaseIndex(string name, ElasticSearchConfig connectionConfiguration, FieldDefinitionCollection fieldDefinitions = null, string analyzer = null, - IValueSetValidator validator = null) + IValueSetValidator validator = null, bool isUmbraco = false) : base(name.ToLowerInvariant(), //TODO: Need to 'clean' the name according to Azure Search rules fieldDefinitions ?? new FieldDefinitionCollection(), validator) { _connectionConfiguration = connectionConfiguration; - + _isUmbraco = isUmbraco; Analyzer = analyzer; ElasticURL = ConfigurationManager.AppSettings[$"examine:ElasticSearch[{name}].Url"]; _searcher = new Lazy(CreateSearcher); @@ -267,9 +267,18 @@ private BulkDescriptor ToElasticSearchDocs(IEnumerable docs, string in protected override void PerformIndexItems(IEnumerable op, Action onComplete) { - if (!IndexExists() && !TempIndexExists()) return; + if (!IndexExists() && !TempIndexExists()) + { + return; + } + if(!_isUmbraco) + { + EnsureIndex(false); + } + var indexesMappedToAlias = _client.Value.GetAlias(descriptor => descriptor.Name(indexAlias)) .Indices.Select(x => x.Key).ToList(); + var indexTarget = isReindexing ? tempindexAlias : indexAlias; diff --git a/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchUmbracoIndex.cs b/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchUmbracoIndex.cs index 488ea6b..c63025d 100644 --- a/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchUmbracoIndex.cs +++ b/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchUmbracoIndex.cs @@ -45,7 +45,7 @@ protected ElasticSearchUmbracoIndex(string name, FieldDefinitionCollection fieldDefinitions = null, string analyzer = null, IValueSetValidator validator = null) - : base(name, connectionConfiguration, fieldDefinitions, analyzer, validator) + : base(name, connectionConfiguration, fieldDefinitions, analyzer, validator,true) { _logger = profilingLogger; }