Fix function name, delete a document from all index nodes before reindexing it

This commit is contained in:
Roberto Rosario
2015-01-03 12:33:01 -04:00
parent 0c0d594f0b
commit bca6355bb8

View File

@@ -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)