You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if I'm being late for this, but what I do is perform the bulk_insert and then grab all the ids of the recently created objects, create a queryset and call the update method of the document.
For instance, let's say you have Blog model and BlogDocument:
blogs_to_create = [Blog(**data) for data in bulk_data]
blogs_created = Blog.objects.bulk_create(blogs_to_create)
blogs_id = [blog.id for blog in blogs_created]
new_blogs_qs = Blog.object.filter(id__in=blogs_id)
BlogDocument().update(new_blogs_qs)
It'd be cool if it could keep the database and elasticsearch index in sync for bulk inserts. I noticed it wasn't a feature yet.
The text was updated successfully, but these errors were encountered: