Switch to requests due to bug in Manticore client
This commit is contained in:
parent
f35eb51aaf
commit
f1cb539ca6
|
@ -14,7 +14,7 @@ from siphashc import siphash
|
|||
from core import r
|
||||
from core.lib.processing import annotate_results, filter_blacklisted, parse_results
|
||||
from core.views import helpers
|
||||
|
||||
import requests
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ def initialise_manticore():
|
|||
"""
|
||||
Initialise the Manticore client
|
||||
"""
|
||||
configuration = manticoresearch.Configuration(host="http://monolith-db-1:9308")
|
||||
configuration = manticoresearch.Configuration(host=settings.MANTICORE_URL)
|
||||
api_client = manticoresearch.ApiClient(configuration)
|
||||
api_instance = manticoresearch.SearchApi(api_client)
|
||||
|
||||
|
@ -83,9 +83,12 @@ def run_query(client, user, search_query):
|
|||
response["took"] = time_took_rounded
|
||||
response["cache"] = True
|
||||
return response
|
||||
response = client.search(search_query)
|
||||
print("PRERESP", response)
|
||||
response = response.to_dict()
|
||||
#response = client.search(search_query)
|
||||
response = requests.post(f"{settings.MANTICORE_URL}/json/search", json=search_query)
|
||||
response = ujson.loads(response.text)
|
||||
if "error" in response and len(response.keys()) == 1:
|
||||
return response
|
||||
#response = response.to_dict()
|
||||
print("RESP", response)
|
||||
if "took" in response:
|
||||
if response["took"] is None:
|
||||
|
@ -326,6 +329,10 @@ def query_results(
|
|||
message_class = "danger"
|
||||
return {"message": message, "class": message_class}
|
||||
# results = results.to_dict()
|
||||
if "error" in results:
|
||||
message = results["error"]
|
||||
message_class = "danger"
|
||||
return {"message": message, "class": message_class}
|
||||
results_parsed = parse_results(results)
|
||||
if annotate:
|
||||
annotate_results(results_parsed)
|
||||
|
|
Loading…
Reference in New Issue