skip fragments with no theme hit
authorJan Szejko <janek37@gmail.com>
Mon, 18 Dec 2017 09:41:11 +0000 (10:41 +0100)
committerJan Szejko <janek37@gmail.com>
Mon, 18 Dec 2017 09:41:11 +0000 (10:41 +0100)
src/search/index.py
src/search/templatetags/search_tags.py

index 70214c5..0bd5c05 100644 (file)
@@ -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
 
index f03aa67..da5a85b 100644 (file)
@@ -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))