in curator/indexlist.py [0:0]
def filter_by_alias(self, aliases=None, exclude=False):
"""
Match indices which are associated with the alias or list of aliases
identified by ``aliases``. Indices must appear in all aliases in list
``aliases`` or a 404 error will result, leading to no indices being matched.
:param aliases: A list of alias names.
:type aliases: list
:param exclude: If ``exclude=True``, this filter will remove matching indices
from ``indices``. If ``exclude=False``, then only matching indices
will be kept in ``indices``. Default is ``False``
"""
self.loggit.debug('Filtering indices matching aliases: "%s"', aliases)
if not aliases:
raise MissingArgument('No value for "aliases" provided')
aliases = ensure_list(aliases)
self.empty_list_check()
for lst in chunk_index_list(self.indices):
try:
# get_alias will either return {} or a NotFoundError.
has_alias = list(
self.client.indices.get_alias(
index=to_csv(lst), name=to_csv(aliases)
).keys()
)
self.loggit.debug('has_alias: %s', has_alias)
except NotFoundError:
# if we see the NotFoundError, we need to set working_list to {}
has_alias = []
for index in lst:
if index in has_alias:
isness = 'is'
condition = True
else:
isness = 'is not'
condition = False
msg = f'{index} {isness} associated with aliases: {aliases}'
self.__excludify(condition, exclude, index, msg)