Fix ZNC queries

This commit is contained in:
2022-08-15 17:59:09 +01:00
parent c9fe1f0b73
commit 4be21cb488
4 changed files with 41 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
def construct_query(index, net, channel, src, num, size, nicks=None):
def construct_query(index, net, channel, src, num, size, type=None, nicks=None):
# Get the initial query
extra_must = []
extra_should = []
@@ -26,8 +26,14 @@ def construct_query(index, net, channel, src, num, size, nicks=None):
]
if index == "int":
fields.append("mtype")
for ctype in types:
extra_should.append({"match": {"mtype": ctype}})
if channel == "*status" or type == "znc":
if {"match": {"channel": channel}} in extra_must:
extra_must.remove({"match": {"channel": channel}})
extra_should2 = []
extra_must.append({"match": {"type": "znc"}})
else:
for ctype in types:
extra_should.append({"match": {"mtype": ctype}})
else:
for ctype in types:
extra_should.append({"match": {"type": ctype}})
@@ -54,5 +60,4 @@ def construct_query(index, net, channel, src, num, size, nicks=None):
"fields": fields,
"_source": False,
}
return query