Implement meta search

This commit is contained in:
2022-07-21 13:52:41 +01:00
parent e7dba44736
commit b50ef76c2d
6 changed files with 184 additions and 22 deletions

View File

@@ -93,7 +93,7 @@ def filter_blacklisted(user, response):
response["exemption"] = True
def run_main_query(client, user, query, custom_query=False, size=None):
def run_main_query(client, user, query, custom_query=False, index=None, size=None):
"""
Low level helper to run an ES query.
Accept a user to pass it to the filter, so we can
@@ -101,14 +101,14 @@ def run_main_query(client, user, query, custom_query=False, size=None):
Accept fields and size, for the fields we want to match and the
number of results to return.
"""
if not index:
index = settings.OPENSEARCH_INDEX_MAIN
if custom_query:
search_query = query
else:
search_query = construct_query(query, size)
try:
response = client.search(
body=search_query, index=settings.OPENSEARCH_INDEX_MAIN
)
response = client.search(body=search_query, index=index)
except RequestError:
print("REQUEST ERROR")
return False