From 5f7c448c182429fb8dbcbdc95df4a981d2c8c572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 12 Jun 2019 19:55:47 -0400 Subject: [PATCH] don't run for docs that already have peer_id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- elasticsearch/peer_id.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/elasticsearch/peer_id.py b/elasticsearch/peer_id.py index 4faf886..130fb9c 100755 --- a/elasticsearch/peer_id.py +++ b/elasticsearch/peer_id.py @@ -71,6 +71,9 @@ def main(): if len(queries) > 0: body = {'query': {'bool': {'must': queries}}} + # don't match docs that already have peer_id field + body['query']['bool']['must_not'] = { 'exists': { 'field': 'peer_id' } } + for index in indices: resp = es.count(index=index, body=body) count = resp.get('count')