Fix source queries
This commit is contained in:
parent
017a05880b
commit
3b8735be72
|
@ -3,7 +3,7 @@ from django.conf import settings
|
||||||
from core.lib.opensearch import annotate_results, filter_blacklisted, parse_results
|
from core.lib.opensearch import annotate_results, filter_blacklisted, parse_results
|
||||||
import manticoresearch
|
import manticoresearch
|
||||||
from core.views.helpers import dedup_list
|
from core.views.helpers import dedup_list
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
def initialise_manticore():
|
def initialise_manticore():
|
||||||
"""
|
"""
|
||||||
|
@ -147,15 +147,17 @@ def query_results(
|
||||||
if source:
|
if source:
|
||||||
sources = [source]
|
sources = [source]
|
||||||
else:
|
else:
|
||||||
sources = settings.MANTICORE_MAIN_SOURCES
|
sources = list(settings.MANTICORE_MAIN_SOURCES)
|
||||||
if request.user.has_perm("core.restricted_sources"):
|
if request.user.has_perm("core.restricted_sources"):
|
||||||
for source_iter in settings.MANTICORE_SOURCES_RESTRICTED:
|
for source_iter in settings.MANTICORE_SOURCES_RESTRICTED:
|
||||||
sources.append(source_iter)
|
sources.append(source_iter)
|
||||||
|
|
||||||
|
print("BEOFRE ADD TOP", add_top)
|
||||||
add_top_tmp = {"bool": {"should": []}}
|
add_top_tmp = {"bool": {"should": []}}
|
||||||
for source_iter in sources:
|
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)
|
add_top.append(add_top_tmp)
|
||||||
|
print("AFTER", add_top)
|
||||||
|
|
||||||
|
|
||||||
# Date/time range
|
# Date/time range
|
||||||
|
@ -246,7 +248,7 @@ def query_results(
|
||||||
search_query["sort"] = sort
|
search_query["sort"] = sort
|
||||||
|
|
||||||
|
|
||||||
print("RUNNING QUERY", search_query)
|
pprint(search_query)
|
||||||
results = run_query(
|
results = run_query(
|
||||||
client,
|
client,
|
||||||
request.user, # passed through run_main_query to filter_blacklisted
|
request.user, # passed through run_main_query to filter_blacklisted
|
||||||
|
@ -278,5 +280,4 @@ def query_results(
|
||||||
"card": results["hits"]["total"],
|
"card": results["hits"]["total"],
|
||||||
"took": results["took"],
|
"took": results["took"],
|
||||||
}
|
}
|
||||||
print("RETURN", context)
|
|
||||||
return context
|
return context
|
|
@ -14,3 +14,4 @@ cryptography
|
||||||
siphashc
|
siphashc
|
||||||
redis
|
redis
|
||||||
sortedcontainers
|
sortedcontainers
|
||||||
|
manticoresearch
|
||||||
|
|
Loading…
Reference in New Issue