Point alias to writable index
This commit is contained in:
parent
7ded6a1320
commit
00962a0b90
|
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue