neptune/core/lib/context.py

39 lines
1.0 KiB
Python
Raw Normal View History

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,
}
},
*extra_must,
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,
}
return query