From 00962a0b9074cd5d1719bd330b6625843bf0b8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrkan=20G=C3=BCran?= Date: Sun, 8 Jan 2023 14:43:53 +0100 Subject: [PATCH] Point alias to writable index --- .../Elsa.Elasticsearch/Extensions/ElasticExtensions.cs | 4 ++-- .../Elsa.Scheduling/Jobs/ConfigureElasticIndicesJob.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/Elsa.Elasticsearch/Extensions/ElasticExtensions.cs b/src/modules/Elsa.Elasticsearch/Extensions/ElasticExtensions.cs index 0d71616dc..a407ea691 100644 --- a/src/modules/Elsa.Elasticsearch/Extensions/ElasticExtensions.cs +++ b/src/modules/Elsa.Elasticsearch/Extensions/ElasticExtensions.cs @@ -45,11 +45,11 @@ public static class ElasticExtensions if (indexExists) continue; var response = client.Indices.Create(indexName, s => s - .Aliases(a => a.Alias(aliasName))); + .Aliases(a => a.Alias(aliasName)) + .Map(m => m.AutoMap(type))); if (response.IsValid) continue; throw response.OriginalException; - } } } \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Jobs/ConfigureElasticIndicesJob.cs b/src/modules/Elsa.Scheduling/Jobs/ConfigureElasticIndicesJob.cs index 3a09518ce..925557af9 100644 --- a/src/modules/Elsa.Scheduling/Jobs/ConfigureElasticIndicesJob.cs +++ b/src/modules/Elsa.Scheduling/Jobs/ConfigureElasticIndicesJob.cs @@ -29,10 +29,11 @@ public class ConfigureElasticIndicesJob : Job var indexExists = (await client.Indices.ExistsAsync(newIndexName)).Exists; if (indexExists) continue; - // Point the alias to the new index + // Point the alias to the new writable index await client.Indices.BulkAliasAsync(aliases => aliases .Remove(a => a.Alias(aliasPointingCurrentIndex).Index(currentIndexName)) - .Add(a => a.Alias(aliasPointingCurrentIndex).Index(newIndexName))); + .Add(a => a.Alias(aliasPointingCurrentIndex).Index(currentIndexName).IsWriteIndex(false)) + .Add(a => a.Alias(aliasPointingCurrentIndex).Index(newIndexName).IsWriteIndex())); } } } \ No newline at end of file