Implement searching int events
This commit is contained in:
@@ -1,17 +1,34 @@
|
||||
def construct_query(net, channel, src, num, size):
|
||||
def construct_query(index, net, channel, src, num, size):
|
||||
# Get the initial query
|
||||
extra_must = []
|
||||
if num:
|
||||
extra_must.append({"match": {"num": num}})
|
||||
if net:
|
||||
extra_must.append({"match": {"net": net}})
|
||||
if channel:
|
||||
extra_must.append({"match": {"channel": channel}})
|
||||
types = ["msg", "notice", "action", "kick", "topic", "mode"]
|
||||
query_should = [{"match": {"type": x}} for x in types]
|
||||
fields = [
|
||||
"nick",
|
||||
"ident",
|
||||
"host",
|
||||
"channel",
|
||||
"ts",
|
||||
"msg",
|
||||
"type",
|
||||
"net",
|
||||
"src",
|
||||
]
|
||||
if index == "int":
|
||||
fields.append("mtype")
|
||||
query_should = [{"match": {"mtype": x}} for x in types]
|
||||
else:
|
||||
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": {
|
||||
@@ -22,17 +39,7 @@ def construct_query(net, channel, src, num, size):
|
||||
]
|
||||
}
|
||||
},
|
||||
"fields": [
|
||||
"nick",
|
||||
"ident",
|
||||
"host",
|
||||
"channel",
|
||||
"ts",
|
||||
"msg",
|
||||
"type",
|
||||
"net",
|
||||
"src",
|
||||
],
|
||||
"fields": fields,
|
||||
"_source": False,
|
||||
}
|
||||
return query
|
||||
|
||||
Reference in New Issue
Block a user