From fdab66a500df9862015dee8377afa8c9c677c4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 5 Jan 2018 15:33:40 +0100 Subject: [PATCH] Elastic: prevent indexing deleted nodes --- pillar/cli/elastic.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pillar/cli/elastic.py b/pillar/cli/elastic.py index 270a80a6..5b2c0bc9 100644 --- a/pillar/cli/elastic.py +++ b/pillar/cli/elastic.py @@ -85,7 +85,10 @@ def _public_project_ids() -> typing.List[bson.ObjectId]: def _reindex_nodes(): db = current_app.db() nodes_coll = db['nodes'] - nodes = nodes_coll.find({'project': {'$in': _public_project_ids()}}) + nodes = nodes_coll.find({ + 'project': {'$in': _public_project_ids()}, + '_deleted': {'$ne': True}, + }) node_count = nodes.count() log.info('Nodes %d will be reindexed in Elastic', node_count)