def set_alias(self, alias, indices, **kwargs):
indices = self.conn._validate_indices(indices)<EOL>try:<EOL><INDENT>old_indices = self.get_alias(alias)<EOL><DEDENT>except IndexMissingException:<EOL><INDENT>old_indices = []<EOL><DEDENT>commands = [['<STR_LIT>', index, alias, {}] for index in old_indices]<EOL>commands.extend([['<STR_LIT>', index, alias,<EOL>self._get_alias_params(**kwargs)] for index in indices])<EOL>if len(commands) > <NUM_LIT:0>:<EOL><INDENT>return self.change_aliases(commands)<EOL><DEDENT>
Set an alias.
(See :ref:`es-guide-reference-api-admin-indices-aliases`)

This handles removing the old list of indices pointed to by the alias.

Warning: there is a race condition in the implementation of this
function - if another client modifies the indices which this alias
points to during this call, the old value of the alias may not be
correctly set.

:param alias: the name of an alias
:param indices: a list of indices