|
|
|
@ -3,7 +3,7 @@ from django.conf import settings
|
|
|
|
|
from core.lib.opensearch import annotate_results, filter_blacklisted, parse_results
|
|
|
|
|
import manticoresearch
|
|
|
|
|
from core.views.helpers import dedup_list
|
|
|
|
|
|
|
|
|
|
from pprint import pprint
|
|
|
|
|
|
|
|
|
|
def initialise_manticore():
|
|
|
|
|
"""
|
|
|
|
@ -147,15 +147,17 @@ def query_results(
|
|
|
|
|
if source:
|
|
|
|
|
sources = [source]
|
|
|
|
|
else:
|
|
|
|
|
sources = settings.MANTICORE_MAIN_SOURCES
|
|
|
|
|
sources = list(settings.MANTICORE_MAIN_SOURCES)
|
|
|
|
|
if request.user.has_perm("core.restricted_sources"):
|
|
|
|
|
for source_iter in settings.MANTICORE_SOURCES_RESTRICTED:
|
|
|
|
|
sources.append(source_iter)
|
|
|
|
|
|
|
|
|
|
print("BEOFRE ADD TOP", add_top)
|
|
|
|
|
add_top_tmp = {"bool": {"should": []}}
|
|
|
|
|
for source_iter in sources:
|
|
|
|
|
add_top_tmp["bool"]["should"].append({"match_phrase": {"src": source_iter}})
|
|
|
|
|
add_top_tmp["bool"]["should"].append({"equals": {"src": source_iter}})
|
|
|
|
|
add_top.append(add_top_tmp)
|
|
|
|
|
print("AFTER", add_top)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Date/time range
|
|
|
|
@ -246,7 +248,7 @@ def query_results(
|
|
|
|
|
search_query["sort"] = sort
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("RUNNING QUERY", search_query)
|
|
|
|
|
pprint(search_query)
|
|
|
|
|
results = run_query(
|
|
|
|
|
client,
|
|
|
|
|
request.user, # passed through run_main_query to filter_blacklisted
|
|
|
|
@ -278,5 +280,4 @@ def query_results(
|
|
|
|
|
"card": results["hits"]["total"],
|
|
|
|
|
"took": results["took"],
|
|
|
|
|
}
|
|
|
|
|
print("RETURN", context)
|
|
|
|
|
return context
|