throw index already exists failure when it exists as alias on creation

make sure to throw the already exists exception, so when indexing into an alias, and it has not propagated yet through the cluster state, it will end up being ignored if it already exists
This commit is contained in:
Shay Banon 2013-10-30 13:47:31 +01:00
parent ed39e79d8f
commit 8a62619fb9
2 changed files with 6 additions and 2 deletions

View File

@ -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");
}
}

View File

@ -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