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
commit b21c3befe36b95c2791061b842572f9d98d39c33 Author: Sebb <s...@apache.org> AuthorDate: Sun May 27 01:28:37 2018 +0100 Mid is not yet implemented --- tools/missing.py | 104 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/tools/missing.py b/tools/missing.py index 6e74b44..88588b0 100755 --- a/tools/missing.py +++ b/tools/missing.py @@ -77,65 +77,69 @@ count = 0 scroll = '30m' then = time.time() elastic = Elastic() -sourceLID = ("%s" if args.notag else "<%s>") % args.source.replace("@", ".").strip("<>") -page = elastic.scan(# defaults to mbox - scroll = scroll, - body = { - "_source" : ['subject','message-id'], - "query" : { - "bool" : { - "must" : { - 'wildcard' if args.wildcard else 'term': { - 'list_raw': sourceLID +if args.source: + sourceLID = ("%s" if args.notag else "<%s>") % args.source.replace("@", ".").strip("<>") + page = elastic.scan(# defaults to mbox + scroll = scroll, + body = { + "_source" : ['subject','message-id'], + "query" : { + "bool" : { + "must" : { + 'wildcard' if args.wildcard else 'term': { + 'list_raw': sourceLID + } + }, + # missing is not supported in ES 5.x + "must_not": { + "exists" : { + "field" : field } - }, - # missing is not supported in ES 5.x - "must_not": { - "exists" : { - "field" : field } } } } - } - ) -print(page) -sid = page['_scroll_id'] -scroll_size = page['hits']['total'] -print("Found %d matches" % scroll_size) -if args.debug: + ) print(page) -js_arr = [] -while (scroll_size > 0): - page = elastic.scroll(scroll_id = sid, scroll = scroll) + sid = page['_scroll_id'] + scroll_size = page['hits']['total'] + print("Found %d matches" % scroll_size) if args.debug: print(page) - sid = page['_scroll_id'] - scroll_size = len(page['hits']['hits']) - for hit in page['hits']['hits']: - doc = hit['_id'] - body = {} - if setField: - body[field] = value - js_arr.append({ - '_op_type': 'update', - '_index': elastic.dbname, - '_type': 'mbox', - '_id': doc, - 'doc': body - }) - count += 1 - source = hit['_source'] - print("Id: %s Msg-id: %s Subject: %s" %(doc, getField(source, 'message-id'), getField(source,'subject'))) - if (count % 500 == 0): - print("Processed %u emails..." % count) + js_arr = [] + while (scroll_size > 0): + page = elastic.scroll(scroll_id = sid, scroll = scroll) + if args.debug: + print(page) + sid = page['_scroll_id'] + scroll_size = len(page['hits']['hits']) + for hit in page['hits']['hits']: + doc = hit['_id'] + body = {} if setField: - update(elastic, js_arr) - js_arr = [] + body[field] = value + js_arr.append({ + '_op_type': 'update', + '_index': elastic.dbname, + '_type': 'mbox', + '_id': doc, + 'doc': body + }) + count += 1 + source = hit['_source'] + print("Id: %s Msg-id: %s Subject: %s" %(doc, getField(source, 'message-id'), getField(source,'subject'))) + if (count % 500 == 0): + print("Processed %u emails..." % count) + if setField: + update(elastic, js_arr) + js_arr = [] + + print("Processed %u emails." % count) + if len(js_arr) > 0: + if setField: + update(elastic, js_arr) -print("Processed %u emails." % count) -if len(js_arr) > 0: - if setField: - update(elastic, js_arr) +if args.mid: + parser.error("--mid: not yet implemented") print("All done, processed %u docs in %u seconds" % (count, time.time() - then)) -- To stop receiving notification emails like this one, please contact s...@apache.org.