ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [incubator-ponymail] branch master updated: Update nullfav.py to work with ES 5.x
Date Thu, 25 Apr 2019 17:43:16 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail.git


The following commit(s) were added to refs/heads/master by this push:
     new 32555fb  Update nullfav.py to work with ES 5.x
32555fb is described below

commit 32555fbb5dae7dce70bcf10b1a9ae9aa78a8f077
Author: Sebb <sebb@apache.org>
AuthorDate: Thu Apr 25 18:42:50 2019 +0100

    Update nullfav.py to work with ES 5.x
    
    This addresses #489 by using the new scan_and_scroll iterator.
---
 CHANGELOG.md     |  1 +
 tools/nullfav.py | 22 +++++-----------------
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index bfd606b..5c196e0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
 ## Changes in 0.12:
 - Bug: Errors with Elasticsearch 5.x in edit-lists.py (#489)
+- Bug: Errors with Elasticsearch 5.x in nullfav.py (#489)
 - Enh: Support scan/scroll for all current versions of ES (#489-contd)
 - Bug/Enh: setup.py tries to install Python modules (#465)
 
diff --git a/tools/nullfav.py b/tools/nullfav.py
index 4d0061e..f630cb2 100755
--- a/tools/nullfav.py
+++ b/tools/nullfav.py
@@ -35,23 +35,11 @@ FAVES='favorites'
 TARGET=None
 
 elastic = Elastic()
-scroll = '5m'
-page = elastic.scan(doc_type='account',
-    scroll = scroll,
-    body = {
-        "_source" : [FAVES],
-    }
-)
-sid = page['_scroll_id']
-scroll_size = page['hits']['total']
-print("Found %d accounts" % scroll_size)
-
-updated=0
-failed=0
-while (scroll_size > 0):
-    page = elastic.scroll(scroll_id = sid, scroll = scroll)
-    sid = page['_scroll_id']
-    scroll_size = len(page['hits']['hits'])
+scroll_size = None # Only show it first time round
+for page in elastic.scan_and_scroll(doc_type='account', body = { "_source" : [FAVES] }):
+    if not scroll_size:
+        scroll_size = page['hits']['total']
+        print("Found %d accounts" % scroll_size)
     for hit in page['hits']['hits']:
         mid = hit['_id']
         source = hit['_source']


Mime
View raw message