Skip to content
Snippets Groups Projects
Verified Commit db7dceb0 authored by Daniel Bessey's avatar Daniel Bessey
Browse files

Fix deleted items are not removed from elasticsearch index

parent 4a75a2e2
Branches
Tags
No related merge requests found
......@@ -34,6 +34,10 @@ def manage_search_index_when_a_set_is_created_or_updated(sender, instance: model
def update_item_in_index_when_model_is_saved(sender, instance: models.item.Item, **kwargs):
if instance.is_deleted:
# Items are soft deleted
search_tasks.delete_item_from_index.delay(instance.id, instance.set.items_index_name)
return
search_tasks.update_item_in_index.delay(instance.id)
......
......@@ -93,7 +93,7 @@ def update_item_in_index(item_id: UUID) -> None:
@shared_task
def delete_item_from_index(item_id: UUID, index_name: str) -> None:
try:
doc = ItemDoc.get(item_id)
doc = ItemDoc.get(item_id, index=index_name)
doc.delete(index=index_name)
except NotFoundError:
pass
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment