mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-24 00:50:35 +00:00
Automatically search remote endpoints if a local search is empty
This commit is contained in:
parent
b84ffeda08
commit
bf99a07153
1 changed files with 8 additions and 6 deletions
|
@ -67,12 +67,14 @@ class Search(View):
|
||||||
|
|
||||||
def book_search(query, _, min_confidence, search_remote=False):
|
def book_search(query, _, min_confidence, search_remote=False):
|
||||||
"""the real business is elsewhere"""
|
"""the real business is elsewhere"""
|
||||||
if search_remote:
|
# try a local-only search
|
||||||
return connector_manager.search(query, min_confidence=min_confidence)
|
if not search_remote:
|
||||||
results = connector_manager.local_search(query, min_confidence=min_confidence)
|
results = connector_manager.local_search(query, min_confidence=min_confidence)
|
||||||
if not results:
|
if results:
|
||||||
return None
|
# gret, we found something
|
||||||
return [{"results": results}]
|
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, *_):
|
def user_search(query, viewer, *_):
|
||||||
|
|
Loading…
Reference in a new issue