2022-08-09 06:20:30 +00:00
|
|
|
def construct_query(net, channel, src, num, size):
|
|
|
|
# Get the initial query
|
|
|
|
extra_must = []
|
|
|
|
if num:
|
|
|
|
extra_must.append({"match": {"num": num}})
|
|
|
|
types = ["msg", "notice", "action", "kick", "topic", "mode"]
|
|
|
|
query_should = [{"match": {"type": x}} for x in types]
|
|
|
|
query = {
|
|
|
|
"size": size,
|
|
|
|
"query": {
|
|
|
|
"bool": {
|
|
|
|
"must": [
|
|
|
|
{"match": {"net": net}},
|
|
|
|
{"match": {"channel": channel}},
|
|
|
|
{"match": {"src": src}},
|
|
|
|
{
|
|
|
|
"bool": {
|
|
|
|
"should": query_should,
|
|
|
|
}
|
|
|
|
},
|
2022-08-09 06:20:30 +00:00
|
|
|
*extra_must,
|
2022-08-09 06:20:30 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2022-08-09 06:20:30 +00:00
|
|
|
"fields": [
|
|
|
|
"nick",
|
|
|
|
"ident",
|
|
|
|
"host",
|
|
|
|
"channel",
|
|
|
|
"ts",
|
|
|
|
"msg",
|
|
|
|
"type",
|
|
|
|
"net",
|
|
|
|
"src",
|
|
|
|
],
|
2022-08-09 06:20:30 +00:00
|
|
|
"_source": False,
|
|
|
|
}
|
2022-08-09 06:20:30 +00:00
|
|
|
return query
|