Opster Team
Overview
This error message is Elasticsearch informing you that you tried to create an alias with the same name as an index that already exists. Since 7.14 it will also produce a similar error message if a data stream exists with the same name of the alias you are trying to create.
What it means
When you send a search request to Elasticsearch you usually(*) specify on which collection(s) of documents you want your search to run. You do that by calling the _search API on one of the following targets:
- An index, which can also be specified as a comma separated list of indices and that also support * as a wildcard operator
- An alias, which will be translated to one or more indices
- A data stream (since 7.9)
- The special _all placeholder that stands for all indices
An alias is a convenient way to hide many indices and data streams behind a facade, so your application doesn’t have to know the names of every index and list them in the search request. You create an alias by simply giving it a name and a pattern of indices you want this alias to translate into:
POST _aliases { "actions": [ { "add": { "index": "house-sensors*", "alias": "house-sensors" } } ] }
Since aliases, indices and data streams share the same namespace, Elasticsearch will produce an error if you try to create an alias with a name that collides with any of those other resource types:
PUT some-index/_doc/1 { "some_field": "some_value" } POST _aliases { "actions": [ { "add": { "index": "some-index*", "alias": "some-index" } } ] } Response: { "error" : { "root_cause" : [ { "type" : "invalid_alias_name_exception", "reason" : "Invalid alias name [some-index], an index exists with the same name as the alias", "index_uuid" : "K75RkLc6StWkkfjtyHbREQ", "index" : "some-index" } ], "type" : "invalid_alias_name_exception", "reason" : "Invalid alias name [some-index], an index exists with the same name as the alias", "index_uuid" : "K75RkLc6StWkkfjtyHbREQ", "index" : "some-index" }, "status" : 400 }
If you are running at least Elasticsearch 7.14 the error message will be slightly different:
{ "error" : { "root_cause" : [ { "type" : "invalid_alias_name_exception", "reason" : "Invalid alias name [some-index], an index or data stream exists with the same name as the alias", "index_uuid" : "K75RkLc6StWkkfjtyHbREQ", "index" : "some-index" } ], "type" : "invalid_alias_name_exception", "reason" : "Invalid alias name [some-index], an index exists with the same name as the alias", "index_uuid" : "K75RkLc6StWkkfjtyHbREQ", "index" : "some-index" }, "status" : 400 }
*The _search API actually allows you to send a search request without specifying against which indices you want your search to run. In that case the search request will consider all indices.
How to resolve it
You should simply choose another alias name, or rename your indices so you can use that name for the alias.
You can use the _cat API to list all existing indices and aliases in your cluster:
GET _cat/indices GET _cat/aliases

Log Context
Log “an index exists with the same name as the alias”classname is AliasValidator.java We extracted the following from Elasticsearch source code for those seeking an in-depth context :
throw new IllegalArgumentException("index name is required"); } IndexMetadata indexNamedSameAsAlias = indexLookup.apply(alias); if (indexNamedSameAsAlias != null) { throw new InvalidAliasNameException(indexNamedSameAsAlias.getIndex(); alias; "an index exists with the same name as the alias"); } } void validateAliasStandalone(String alias; String indexRouting) { if (!Strings.hasText(alias)) {
Find & fix Elasticsearch problems
Opster AutoOps diagnoses & fixes issues in Elasticsearch based on analyzing hundreds of metrics.
Fix Your Cluster IssuesConnect in under 2 minutes
Lourens Rozema
CTO at Omnidots