@classmethod
def ensure_indexes(cls, **kwargs):
    """Ensure this any indexes declared on this index :class:`Document`.

        This is an administrative task and should be done with care as
        (re)building large indexes can make a database unusable for some time.
        Any additional `kwargs` are passed to
        :meth:`pymongo.collection.Collection.ensure_index`.

        """
    for index in cls.indexes:
        kwargs['unique'] = index.get('unique', False)
        cls.collection.ensure_index(index['fields'], **kwargs)
