From d30a11c8f715e69ce5255ad4b6498cac2c26ae01 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Wed, 21 Mar 2018 02:17:58 +0100 Subject: [PATCH] Do not index a document if it's empty The prepare_node_data function returns an empty dict if the node is not of the INDEX_ALLOWED_NODE_TYPES, or if it's not published, etc. --- pillar/celery/search_index_tasks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pillar/celery/search_index_tasks.py b/pillar/celery/search_index_tasks.py index 4760b823..2f99003c 100644 --- a/pillar/celery/search_index_tasks.py +++ b/pillar/celery/search_index_tasks.py @@ -177,6 +177,10 @@ def node_save(node_id: str): to_index = prepare_node_data(node_id) + if not to_index: + log.debug('Node %s will not be indexed', node_id) + return + for searchoption in current_app.config['SEARCH_BACKENDS']: searchmodule = SEARCH_BACKENDS[searchoption] searchmodule.index_node_save(to_index)