def generate_aliases_for_removal(): current_aliases = es.get_aliases() aliases_for_removal = collections.defaultdict(lambda: []) for item, tmp in current_aliases.items(): for iname in list(tmp.get('aliases', {}).keys()): aliases_for_removal[iname].append(item) return aliases_for_removal
def get_indices_from_aliases(search_aliases=None): """Returns indices associated with aliases :param search_aliases: Search aliases to get indices for. :type search_aliases: list. :returns: A list of indices """ if not search_aliases: search_aliases = [] indices = [] for alias in search_aliases: indices.extend([ index for index, aliases in es.get_aliases().items() if alias in aliases['aliases'].keys() ]) return indices