From 05e5b36046d980e84776978660f420b008db4879 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Mon, 18 Dec 2017 10:41:11 +0100 Subject: [PATCH] skip fragments with no theme hit --- src/search/index.py | 2 +- src/search/templatetags/search_tags.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/search/index.py b/src/search/index.py index 70214c554..0bd5c0530 100644 --- a/src/search/index.py +++ b/src/search/index.py @@ -670,7 +670,7 @@ class SearchResult(object): m.update(f[self.OTHER]) hits.append(m) - hits.sort(lambda a, b: cmp(a['score'], b['score']), reverse=True) + hits.sort(key=lambda h: h['score'], reverse=True) self._processed_hits = hits diff --git a/src/search/templatetags/search_tags.py b/src/search/templatetags/search_tags.py index f03aa6762..da5a85bc7 100644 --- a/src/search/templatetags/search_tags.py +++ b/src/search/templatetags/search_tags.py @@ -25,7 +25,7 @@ def book_searched(context, result): # We don't need hits which lead to sections but do not have # snippets. hits = filter(lambda (idx, h): - result.snippets[idx] is not None or 'fragment' in h, + result.snippets[idx] is not None or ('fragment' in h and h['themes_hit']), enumerate(result.hits)) # print "[tmpl: from %d hits selected %d]" % (len(result.hits), len(hits)) -- 2.20.1