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

def set_alias(self, alias, indices, **kwargs):

    indices = self.conn._validate_indices(indices)
    try:
        old_indices = self.get_alias(alias)
    except IndexMissingException:
        old_indices = []
    commands = [['remove', index, alias, {}] for index in old_indices]
    commands.extend([['add', index, alias, self._get_alias_params(**kwargs)] for index in indices])
    if (len(commands) > 0):
        return self.change_aliases(commands)
