Skip to content

Commit

Permalink
fix double creation of indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
abi committed Nov 29, 2019
1 parent 6889c64 commit 26ac482
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# version format
version: 0.3.3.{build}
version: 0.3.4.{build}

image: Visual Studio 2019

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ElasticClient> _client;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -214,7 +216,8 @@ private void CreateNewIndex(bool indexExists)
.Add(add => add.Index(indexName).Alias(tempindexAlias))
);
}


_exists = true;
}
}

Expand Down Expand Up @@ -272,17 +275,10 @@ private BulkDescriptor ToElasticSearchDocs(IEnumerable<ValueSet> docs, string in

protected override void PerformIndexItems(IEnumerable<ValueSet> op, Action<IndexOperationEventArgs> 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;

Expand Down

0 comments on commit 26ac482

Please sign in to comment.