From bf99a07153e5319dee47f22e244dbad7bbc4e638 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 28 Jul 2021 13:29:24 -0700 Subject: [PATCH] Automatically search remote endpoints if a local search is empty --- bookwyrm/views/search.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bookwyrm/views/search.py b/bookwyrm/views/search.py index d15fc6a8..7e0c8fee 100644 --- a/bookwyrm/views/search.py +++ b/bookwyrm/views/search.py @@ -67,12 +67,14 @@ class Search(View): def book_search(query, _, min_confidence, search_remote=False): """the real business is elsewhere""" - if search_remote: - return connector_manager.search(query, min_confidence=min_confidence) - results = connector_manager.local_search(query, min_confidence=min_confidence) - if not results: - return None - return [{"results": results}] + # try a local-only search + if not search_remote: + results = connector_manager.local_search(query, min_confidence=min_confidence) + if results: + # gret, we found something + return [{"results": results}] + # if there weere no local results, or the request was for remote, search all sources + return connector_manager.search(query, min_confidence=min_confidence) def user_search(query, viewer, *_):