diff --git a/mayan/apps/document_indexing/api.py b/mayan/apps/document_indexing/api.py index 2d76bc0301..8b6ec5f1f9 100644 --- a/mayan/apps/document_indexing/api.py +++ b/mayan/apps/document_indexing/api.py @@ -13,7 +13,7 @@ logger = logging.getLogger(__name__) # External functions -def update_indexes(document): +def index_document(document): """ Update or create all the index instances related to a document """ @@ -21,6 +21,9 @@ def update_indexes(document): warnings = [] + for index_node in IndexInstanceNode.objects.filter(documents=document): + index_node.documents.remove(document) + # Only update indexes where the document type is found or that do not have any document type specified # TODO: explicit document type selection, none != all for index in Index.objects.filter(Q(enabled=True) & (Q(document_types=None) | Q(document_types=document.document_type))): @@ -86,4 +89,4 @@ def task_delete_empty_index_nodes_recursive(instance_node): # same conditions parent = instance_node.parent instance_node.delete() - delete_empty_indexes(parent) + task_delete_empty_index_nodes_recursive(parent)