'Get a dict holding an entry for each index which exists.
If include_alises is True, the dict will also contain entries for
aliases.
The key for each entry in the dict is the index or alias name.  The
value is a dict holding the following properties:
- num_docs: Number of documents in the index or alias.
- alias_for: Only present for an alias: holds a list of indices which
this is an alias for.'

def get_indices(self, include_aliases=False):

    state = self.conn.cluster.state()
    status = self.status()
    result = {}
    indices_status = status['indices']
    indices_metadata = state['metadata']['indices']
    for index in sorted(indices_status.keys()):
        info = indices_status[index]
        try:
            num_docs = info['docs']['num_docs']
        except KeyError:
            num_docs = 0
        result[index] = dict(num_docs=num_docs)
        if (not include_aliases):
            continue
        try:
            metadata = indices_metadata[index]
        except KeyError:
            continue
        for alias in metadata.get('aliases', []):
            try:
                alias_obj = result[alias]
            except KeyError:
                alias_obj = {}
                result[alias] = alias_obj
            alias_obj['num_docs'] = (alias_obj.get('num_docs', 0) + num_docs)
            try:
                alias_obj['alias_for'].append(index)
            except KeyError:
                alias_obj['alias_for'] = [index]
    return result
