Implement meta search
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user