def monitor(index, delta, query_string):
click.clear()
def cnt():
q = Q('query_string', query=query_string)
s = Search(
using=es.client,
index=index).query(q)
return s.count()
N = cnt()
tot = Search(using=es.client, index=index).count()
if not delta:
N = tot
log.info('Processing %d records (total: %d)', N, tot)
click.echo('You can exit by CTRL-C: results will still process')
bar = SlowOverallFancyBar('', max=N, grand_total=tot)
while True:
time.sleep(5.0)
try:
n = cnt()
if isinstance(n, int):
if delta:
done = N - n
else:
done = n
bar.goto(done)
except Exception as e:
log.warn('Cannot count: %s', e)
bar.finish()
评论列表
文章目录