Skip to content

Commit

Permalink
Update bulk_generate_documents to use object_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusher committed Sep 13, 2024
1 parent dc7072f commit 8b526ed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/wagtail_vector_index/storage/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,11 @@ def generate_documents(
@transaction.atomic
def bulk_generate_documents(self, objects, *, embedding_backend):
objects_by_key = {ModelKey.from_instance(obj): obj for obj in objects}
documents = Document.objects.filter(object_key__in=objects_by_key.keys())
documents = Document.objects.for_keys(objects_by_key.keys())

documents_by_object_key = defaultdict(list)
for document in documents:
documents_by_object_key[document.object_key].append(document)
documents_by_object_key[document.object_keys[0]].append(document)

objects_to_rebuild = {}

Expand Down

0 comments on commit 8b526ed

Please sign in to comment.