# Index Alias Using NEST

**URL:** https://discuss.elastic.co/t/index-alias-using-nest/213220
**Category:** Elasticsearch
**Created:** [December 27, 2019, 6:27pm UTC](https://discuss.elastic.co/t/index-alias-using-nest/213220 "2019-12-27T18:27:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![han1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han1/32/20141_2.png) [@han1](https://discuss.elastic.co/u/han1)
#### Post date: [December 27, 2019, 6:27pm UTC](https://discuss.elastic.co/t/index-alias-using-nest/213220/1 "2019-12-27T18:27:10Z")

</div>

As usual No doc assistance when using NEST. We came across this OLD code on Stackoverflow:

```
> createIndexResponse = client.CreateIndex(indices[1]);
> 
> // wait for index-v2 to be operable
> var clusterHealthResponse = client.ClusterHealth(c => c
> .WaitForStatus(WaitForStatus.Yellow)
> .Index(indices[1]));
> 
> // swap the alias
> var bulkAliasResponse = client.Alias(ba => ba
> .Add(add => add.Alias(alias).Index(indices[1]))
> .Remove(remove => remove.Alias(alias).Index("*"))
> );
> 
> // verify that the alias only exists on index-v2
> var aliasResponse = client.GetAlias(a => a.Name(alias));

```

But we are confused:  
1- There is no ClusterHealth anymore.  
2- The code that first Adds and then removes alias from All indexes - will that not remove the alias as well from the new index?

Would appreciate any assistance.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 24, 2020, 6:27pm UTC](https://discuss.elastic.co/t/index-alias-using-nest/213220/2 "2020-01-24T18:27:30Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
