From 2889c15dc8c392f12a67e303544eb0a8fde5bd9c Mon Sep 17 00:00:00 2001 From: j Date: Sun, 1 Dec 2019 17:35:54 +0100 Subject: [PATCH] remove documents from index --- pandora/document/fulltext.py | 7 ++++--- pandora/document/models.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora/document/fulltext.py b/pandora/document/fulltext.py index d64cd2582..6779113cb 100644 --- a/pandora/document/fulltext.py +++ b/pandora/document/fulltext.py @@ -36,12 +36,13 @@ class FulltextMixin: return self.data.get('text', '') return '' - def delete_fulltext(self): - res = self.elasticsearch().delete(index=self._ES_INDEX, doc_type='document', id=self.id) - def has_fulltext_key(): return bool([k for k in settings.CONFIG['documentKeys'] if k.get('fulltext')]) + def delete_fulltext(self): + if self.has_fulltext_key(): + res = self.elasticsearch().delete(index=self._ES_INDEX, doc_type='document', id=self.id) + def update_fulltext(self): if self.has_fulltext_key(): text = self.extract_fulltext() diff --git a/pandora/document/models.py b/pandora/document/models.py index 0c61f0192..c938c2609 100644 --- a/pandora/document/models.py +++ b/pandora/document/models.py @@ -653,6 +653,7 @@ def delete_document(sender, **kwargs): if t.file: t.delete_cache() t.file.delete(save=False) + t.delete_fulltext() pre_delete.connect(delete_document, sender=Document) class ItemProperties(models.Model):