'Points `_index` to `new_index` and deletes `_index` if delete=True.
The ES `update_aliases` is atomic.'

def update_aliases(self, new_index, delete=True):

    old_index = None
    try:
        aliases = self.es.indices.get_alias(name=self._index)
        if (aliases and list(aliases.keys())):
            old_index = list(aliases.keys())[0]
    except exceptions.NotFoundError:
        pass
    actions = []
    if old_index:
        actions.append({'remove': {'index': old_index, 'alias': self._index}})
    actions.append({'add': {'index': new_index, 'alias': self._index}})
    self.es.indices.update_aliases(body={'actions': actions})
    if (delete and old_index):
        self.es.indices.delete(index=old_index)
