From b9b91f729f25657c02a19a71026b5aa8ff82ed09 Mon Sep 17 00:00:00 2001 From: koniu Date: Fri, 21 Dec 2012 14:44:22 +0000 Subject: [PATCH] py: allow limiting the number of results --- views/settings.tpl | 2 ++ webui.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/views/settings.tpl b/views/settings.tpl index a50a042..628bfa2 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -3,6 +3,8 @@
Find similar (1 or 0, show "squats" and "squatter") + Max results (maximum number of results to show) +
Context words (number of words shown in search results) diff --git a/webui.py b/webui.py index fcdba64..5d45c67 100755 --- a/webui.py +++ b/webui.py @@ -27,6 +27,7 @@ DEFAULTS = { 'timefmt': '%c', 'dirdepth': 3, 'maxchars': 500, + 'maxresults': 100, } # sort fields/labels @@ -165,7 +166,7 @@ def recoll_search(q, sort, ascending): nres = query.execute(q, int(config['stem'])) except: nres = 0 - for i in range(0, nres): + for i in range(0, min(nres, int(config['maxresults']))): doc = query.fetchone() d = {} for f in FIELDS: