# Fail to create alias using transport client

**URL:** <https://discuss.elastic.co/t/fail-to-create-alias-using-transport-client/79550>\
**Category:** Elasticsearch\
**Created:** [March 22, 2017, 8:19am UTC](https://discuss.elastic.co/t/fail-to-create-alias-using-transport-client/79550 "2017-03-22T08:19:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cherry\_Zhang](https://avatars.discourse-cdn.com/v4/letter/c/e99b99/32.png) [@Cherry\_Zhang](https://discuss.elastic.co/u/Cherry_Zhang)\
**Post date:** [March 22, 2017, 8:19am UTC](https://discuss.elastic.co/t/fail-to-create-alias-using-transport-client/79550/1 "2017-03-22T08:19:12Z")

</div>

I use below command to add an alias

`client.admin().indices().prepareAliases().addAlias(index, alias).execute().actionGet()`;

but always gets an exception:

`org.elasticsearch.indices.InvalidAliasNameException: Invalid alias name [active_index], an index exists with the same name as the alias`

when I use:

`client.admin().indices().prepareAliases().removeAlias(index, alias).execute().actionGet();`

to remove all index from an alias, will an index has the same name with alias be left in the system?

---

<div class="post-metadata">

**Author:** ![wenpos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wenpos/32/15326_2.png) [@wenpos](https://discuss.elastic.co/u/wenpos)\
**Post date:** [March 23, 2017, 12:33am UTC](https://discuss.elastic.co/t/fail-to-create-alias-using-transport-client/79550/2 "2017-03-23T00:33:14Z")

</div>

The alias name must be one of the current index names. You may get all the index names before and make sure the alias name is not anyone of the names.

---

<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:** [April 20, 2017, 12:33am UTC](https://discuss.elastic.co/t/fail-to-create-alias-using-transport-client/79550/3 "2017-04-20T00:33:25Z")

</div>

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