def index(method=None, delete=False):
if method is None:<EOL><INDENT>return partial(index, delete=delete)<EOL><DEDENT>@wraps(method)<EOL>def wrapper(self_or_cls, *args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>result = method(self_or_cls, *args, **kwargs)<EOL>try:<EOL><INDENT>if delete:<EOL><INDENT>self_or_cls.indexer.delete(result)<EOL><DEDENT>else:<EOL><INDENT>self_or_cls.indexer.index(result)<EOL><DEDENT><DEDENT>except RequestError:<EOL><INDENT>current_app.logger.exception('<STR_LIT>'.format(result))<EOL><DEDENT>return result<EOL><DEDENT>return wrapper<EOL>
Decorator to update index.

    :param method: Function wrapped. (Default: ``None``)
    :param delete: If `True` delete the indexed record. (Default: ``None``)