def remove_object(instance): indexed_instance = get_indexed_instance(instance, check_exists=False) if indexed_instance: for backend_name, backend in get_search_backends_with_name(with_auto_update=True): try: backend.delete(indexed_instance) except Exception: # Catch and log all errors logger.exception("Exception raised while deleting %r from the '%s' search backend", indexed_instance, backend_name)
def insert_or_update_object(instance): indexed_instance = get_indexed_instance(instance) if indexed_instance: for backend_name, backend in get_search_backends_with_name(with_auto_update=True): try: backend.add(indexed_instance) except Exception: # Catch and log all errors logger.exception("Exception raised while adding %r into the '%s' search backend", indexed_instance, backend_name)