diff --git a/appveyor.yml b/appveyor.yml index d9f399f..93ddd4b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ # version format -version: 0.3.3.{build} +version: 0.3.4.{build} image: Visual Studio 2019 diff --git a/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchBaseIndex.cs b/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchBaseIndex.cs index cc3deae..2b3beef 100644 --- a/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchBaseIndex.cs +++ b/source/Novicell.Examine.ElasticSearch/Indexers/ElasticSearchBaseIndex.cs @@ -17,6 +17,7 @@ namespace Novicell.Examine.ElasticSearch.Indexers public class ElasticSearchBaseIndex : BaseIndexProvider, IDisposable { public readonly ElasticSearchConfig _connectionConfiguration; + private bool? _exists; private bool isReindexing = false; private bool _isUmbraco = false; public readonly Lazy _client; @@ -177,6 +178,7 @@ private static string FromLuceneAnalyzer(string analyzer) public void EnsureIndex(bool forceOverwrite) { + if (!forceOverwrite && _exists.HasValue && _exists.Value) return; var indexExists = IndexExists(); if (indexExists && !forceOverwrite) return; @@ -214,7 +216,8 @@ private void CreateNewIndex(bool indexExists) .Add(add => add.Index(indexName).Alias(tempindexAlias)) ); } - + + _exists = true; } } @@ -272,17 +275,10 @@ private BulkDescriptor ToElasticSearchDocs(IEnumerable docs, string in protected override void PerformIndexItems(IEnumerable op, Action onComplete) { - if (!IndexExists() && !TempIndexExists() && _isUmbraco) - { - return; - } - - EnsureIndex(false); - - + var indexesMappedToAlias = _client.Value.GetAlias(descriptor => descriptor.Name(indexAlias)) .Indices.Select(x => x.Key).ToList(); - + EnsureIndex(false); var indexTarget = isReindexing ? tempindexAlias : indexAlias;