Gracefully handle invalid queries
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from django.conf import settings
|
||||
from opensearchpy import OpenSearch
|
||||
from opensearchpy.exceptions import RequestError
|
||||
|
||||
|
||||
def initialise_opensearch():
|
||||
@@ -91,7 +92,10 @@ def run_main_query(client, user, query, fields=None, size=None):
|
||||
return False
|
||||
search_query = construct_query(query, fields, size)
|
||||
# fmt: off
|
||||
response = client.search(body=search_query,
|
||||
index=settings.OPENSEARCH_INDEX_MAIN)
|
||||
try:
|
||||
response = client.search(body=search_query,
|
||||
index=settings.OPENSEARCH_INDEX_MAIN)
|
||||
except RequestError:
|
||||
return False
|
||||
filter_blacklisted(user, response)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user