Update internal index name

This commit is contained in:
Mark Veidemanis 2022-09-05 07:20:30 +01:00
parent 0882d3f0da
commit f35eb51aaf
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
7 changed files with 18 additions and 11 deletions

View File

@ -18,7 +18,7 @@ OPENSEARCH_SOURCES_RESTRICTED = ["irc"]
MANTICORE_URL = "http://monolith-db-1:9308" MANTICORE_URL = "http://monolith-db-1:9308"
MANTICORE_INDEX_MAIN = "main" MANTICORE_INDEX_MAIN = "main"
MANTICORE_INDEX_META = "meta" MANTICORE_INDEX_META = "meta"
MANTICORE_INDEX_INT = "int" MANTICORE_INDEX_INT = "internal"
MANTICORE_MAIN_SIZES = ["20", "50", "100", "200", "400", "800"] MANTICORE_MAIN_SIZES = ["20", "50", "100", "200", "400", "800"]
MANTICORE_MAIN_SIZES_ANON = ["20", "50", "100"] MANTICORE_MAIN_SIZES_ANON = ["20", "50", "100"]

View File

@ -25,7 +25,7 @@ def construct_query(index, net, channel, src, num, size, type=None, nicks=None):
"src", "src",
"tokens", "tokens",
] ]
if index == "int": if index == "internal":
fields.append("mtype") fields.append("mtype")
if channel == "*status" or type == "znc": if channel == "*status" or type == "znc":
if {"match": {"channel": channel}} in extra_must: if {"match": {"channel": channel}} in extra_must:

View File

@ -84,7 +84,12 @@ def run_query(client, user, search_query):
response["cache"] = True response["cache"] = True
return response return response
response = client.search(search_query) response = client.search(search_query)
print("PRERESP", response)
response = response.to_dict() response = response.to_dict()
print("RESP", response)
if "took" in response:
if response["took"] is None:
return None
filter_blacklisted(user, response) filter_blacklisted(user, response)
# Write cache # Write cache
@ -147,7 +152,7 @@ def query_results(
} }
if index == "meta": if index == "meta":
index = settings.MANTICORE_INDEX_META index = settings.MANTICORE_INDEX_META
elif index == "int": elif index == "internal":
index = settings.MANTICORE_INDEX_INT index = settings.MANTICORE_INDEX_INT
else: else:
message = "Index is not valid." message = "Index is not valid."
@ -317,7 +322,9 @@ def query_results(
search_query, search_query,
) )
if not results: if not results:
return False message = "Error running query"
message_class = "danger"
return {"message": message, "class": message_class}
# results = results.to_dict() # results = results.to_dict()
results_parsed = parse_results(results) results_parsed = parse_results(results)
if annotate: if annotate:

View File

@ -383,7 +383,7 @@ def query_results(
} }
if index == "meta": if index == "meta":
index = settings.OPENSEARCH_INDEX_META index = settings.OPENSEARCH_INDEX_META
elif index == "int": elif index == "internal":
index = settings.OPENSEARCH_INDEX_INT index = settings.OPENSEARCH_INDEX_INT
else: else:
message = "Index is not valid." message = "Index is not valid."

View File

@ -106,7 +106,7 @@
"channel": "*status", "channel": "*status",
"time": "None", "time": "None",
"date": "None", "date": "None",
"index": "int", "index": "internal",
"type": "znc", "type": "znc",
"mtype": "None", "mtype": "None",
"nick": "*status", "nick": "*status",
@ -196,7 +196,7 @@
"channel": "{{ sinst.entity }}", "channel": "{{ sinst.entity }}",
"time": "None", "time": "None",
"date": "None", "date": "None",
"index": "int", "index": "internal",
"type": "auth", "type": "auth",
"mtype": "None", "mtype": "None",
"nick": "{{ sinst.entity }}", "nick": "{{ sinst.entity }}",

View File

@ -354,10 +354,10 @@
<option value="main">Main</option> <option value="main">Main</option>
{% endif %} {% endif %}
{% if params.index == 'int' %} {% if params.index == 'internal' %}
<option selected value="int">Internal</option> <option selected value="internal">Internal</option>
{% else %} {% else %}
<option value="int">Internal</option> <option value="internal">Internal</option>
{% endif %} {% endif %}
{% if params.index == 'meta' %} {% if params.index == 'meta' %}

View File

@ -338,7 +338,7 @@ class DrilldownContextModal(APIView):
query = True query = True
if ( if (
query_params["index"] == "int" query_params["index"] == "internal"
and query_params["mtype"] == "msg" and query_params["mtype"] == "msg"
and not type == "query" and not type == "query"
): ):