diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index 6f2c6c7d99a..af643ddcf42 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -506,7 +506,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { throw new InvalidIndexNameException(new Index(request.index), request.index, "must not contain the following characters " + Strings.INVALID_FILENAME_CHARS); } if (state.metaData().aliases().containsKey(request.index)) { - throw new InvalidIndexNameException(new Index(request.index), request.index, "an alias with the same name already exists"); + throw new IndexAlreadyExistsException(new Index(request.index), "already exists as alias"); } } diff --git a/src/main/java/org/elasticsearch/indices/IndexAlreadyExistsException.java b/src/main/java/org/elasticsearch/indices/IndexAlreadyExistsException.java index 625bb13527a..ff60c5ea82b 100644 --- a/src/main/java/org/elasticsearch/indices/IndexAlreadyExistsException.java +++ b/src/main/java/org/elasticsearch/indices/IndexAlreadyExistsException.java @@ -29,7 +29,11 @@ import org.elasticsearch.rest.RestStatus; public class IndexAlreadyExistsException extends IndexException { public IndexAlreadyExistsException(Index index) { - super(index, "Already exists"); + this(index, "already exists"); + } + + public IndexAlreadyExistsException(Index index, String message) { + super(index, message); } @Override