Commit 463e64fe authored by mhellka's avatar mhellka
Browse files

Be nice and limit search results per page to a reasonable number.

parent 953321a3
......@@ -35,18 +35,22 @@ def search(ctx, args):
found = 0
page = None
while limit > found:
page = client.search(vault, query, limit=limit - found, order=order, scroll=scroll)
page = client.search(vault, query, limit=min(1024, limit - found), order=order, scroll=scroll)
if not page.hits:
break # no more results
for hit in page.hits[:limit - found] if page.hits else []:
for hit in page.hits or []:
found += 1
if hit.type == 'archive':
print("{}".format(hit.id))
elif hit.type == 'file':
print("{}\t{}".format(hit.id, hit.name))
if found >= limit:
break
if args.no_scroll:
break
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment