dont prevent search when backend throws an exception or times out

This commit is contained in:
Nick Sweeting 2021-04-10 08:18:13 -04:00
parent 9f05cf8283
commit 52429b8d15
2 changed files with 5 additions and 1 deletions

View file

@ -15,6 +15,7 @@ class SearchResultsAdminMixin:
qsearch = query_search_index(search_term)
qs = qs | qsearch
except Exception as err:
print(f'[!] Error while using search backend: {err.__class__.__name__} {err}')
messages.add_message(request, messages.WARNING, f'Error from the search backend, only showing results from default admin search fields - Error: {err}')
return qs, use_distinct

View file

@ -223,7 +223,10 @@ class PublicIndexView(ListView):
query = self.request.GET.get('q')
if query and query.strip():
qs = qs.filter(Q(title__icontains=query) | Q(url__icontains=query) | Q(timestamp__icontains=query) | Q(tags__name__icontains=query))
qs = qs | query_search_index(query)
try:
qs = qs | query_search_index(query)
except Exception as err:
print(f'[!] Error while using search backend: {err.__class__.__name__} {err}')
return qs
def get(self, *args, **kwargs):