From 3b8735be721b1c441d8e51a1332834ca2e15d57e Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Tue, 6 Sep 2022 09:41:07 +0100 Subject: [PATCH] Fix source queries --- core/lib/manticore.py | 11 ++++++----- docker/prod/requirements.prod.txt | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/lib/manticore.py b/core/lib/manticore.py index 1132a95..6d2a13a 100644 --- a/core/lib/manticore.py +++ b/core/lib/manticore.py @@ -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 \ No newline at end of file diff --git a/docker/prod/requirements.prod.txt b/docker/prod/requirements.prod.txt index d05be0c..99d1c15 100644 --- a/docker/prod/requirements.prod.txt +++ b/docker/prod/requirements.prod.txt @@ -14,3 +14,4 @@ cryptography siphashc redis sortedcontainers +manticoresearch