Implement more elements on Insights page

This commit is contained in:
2022-07-21 13:52:10 +01:00
parent 9de9ddff6f
commit 17d465171b
11 changed files with 291 additions and 152 deletions

View File

@@ -93,7 +93,7 @@ def filter_blacklisted(user, response):
response["exemption"] = True
def run_main_query(client, user, query, size=None):
def run_main_query(client, user, query, custom_query=False, size=None):
"""
Low level helper to run an ES query.
Accept a user to pass it to the filter, so we can
@@ -101,7 +101,10 @@ def run_main_query(client, user, query, size=None):
Accept fields and size, for the fields we want to match and the
number of results to return.
"""
search_query = construct_query(query, size)
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
@@ -131,7 +134,7 @@ def query_results(request, size=None):
client,
request.user,
query,
size,
size=size,
)
if not results:
return False