- text_phrase = SearchResult.aggregate(srch.search_phrase(toks, 'content', fuzzy=fuzzy, tokens_cache=tokens_cache))
- [r.process_hits() for r in text_phrase]
+ text_phrase = SearchResult.aggregate(srch.search_phrase(toks, 'content', fuzzy=fuzzy, tokens_cache=tokens_cache, snippets=True, book=False))
+
+ everywhere = srch.search_everywhere(toks, fuzzy=fuzzy, tokens_cache=tokens_cache)
+
+ def already_found(results):
+ def f(e):
+ for r in results:
+ if e.book_id == r.book_id:
+ results.append(e)
+ return True
+ return False
+ return f
+ f = already_found(author_results + title_results)
+ everywhere = filter(lambda x: not f(x), everywhere)
+
+ author_results = SearchResult.aggregate(author_results)
+ title_results = SearchResult.aggregate(title_results)