def get_indices(self, include_aliases=False):
state = self.conn.cluster.state()<EOL>status = self.status()<EOL>result = {}<EOL>indices_status = status['<STR_LIT>']<EOL>indices_metadata = state['<STR_LIT>']['<STR_LIT>']<EOL>for index in sorted(indices_status.keys()):<EOL><INDENT>info = indices_status[index]<EOL>try:<EOL><INDENT>num_docs = info['<STR_LIT>']['<STR_LIT>']<EOL><DEDENT>except KeyError:<EOL><INDENT>num_docs = <NUM_LIT:0><EOL><DEDENT>result[index] = dict(num_docs=num_docs)<EOL>if not include_aliases:<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>metadata = indices_metadata[index]<EOL><DEDENT>except KeyError:<EOL><INDENT>continue<EOL><DEDENT>for alias in metadata.get('<STR_LIT>', []):<EOL><INDENT>try:<EOL><INDENT>alias_obj = result[alias]<EOL><DEDENT>except KeyError:<EOL><INDENT>alias_obj = {}<EOL>result[alias] = alias_obj<EOL><DEDENT>alias_obj['<STR_LIT>'] = alias_obj.get('<STR_LIT>', <NUM_LIT:0>) + num_docs<EOL>try:<EOL><INDENT>alias_obj['<STR_LIT>'].append(index)<EOL><DEDENT>except KeyError:<EOL><INDENT>alias_obj['<STR_LIT>'] = [index]<EOL><DEDENT><DEDENT><DEDENT>return result<EOL>
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.