def METHOD_NAME(instance):
    """Return function for updating search index of instance."""
    components = instance.index_contents()
    pk = instance.pk
    def on_commit():
        search_vector_list = []
        for weight, text in components.items():
            search_vector_list.append(
                SearchVector(Value(text), weight=weight)
            )
        search_vectors = search_vector_list[0]
        for search_vector in search_vector_list[1:]:
            search_vectors += search_vector
        instance.__class__.objects.filter(pk=pk).update(
            search_vector=search_vectors
        )
        print(f'Rebuilt index for {instance} ({instance.__class__})')
    return on_commit