Fix some Manticore queries

This commit is contained in:
2022-09-06 11:53:32 +01:00
parent 3b8735be72
commit 87324de666
6 changed files with 215 additions and 225 deletions

View File

@@ -4,9 +4,9 @@ def construct_query(index, net, channel, src, num, size, type=None, nicks=None):
extra_should = []
extra_should2 = []
if num:
extra_must.append({"match": {"num": num}})
extra_must.append({"equals": {"num": num}})
if net:
extra_must.append({"match": {"net": net}})
extra_must.append({"match_phrase": {"net": net}})
if channel:
extra_must.append({"match": {"channel": channel}})
if nicks:
@@ -52,31 +52,36 @@ def construct_query(index, net, channel, src, num, size, type=None, nicks=None):
extra_should.append({"match": {"nick": channel}})
else:
for ctype in types:
extra_should.append({"match": {"mtype": ctype}})
extra_should.append({"equals": {"mtype": ctype}})
else:
for ctype in types:
extra_should.append({"match": {"type": ctype}})
query = {
"size": size,
"index": index,
"limit": size,
"query": {
"bool": {
"must": [
{"match": {"src": src}},
{
"bool": {
"should": [*extra_should],
}
},
{
"bool": {
"should": [*extra_should2],
}
},
# {"equals": {"src": src}},
# {
# "bool": {
# "should": [*extra_should],
# }
# },
# {
# "bool": {
# "should": [*extra_should2],
# }
# },
*extra_must,
]
}
},
"fields": fields,
"_source": False,
# "_source": False,
}
if extra_should:
query["query"]["bool"]["must"].append({"bool": {"should": [*extra_should]}})
if extra_should2:
query["query"]["bool"]["must"].append({"bool": {"should": [*extra_should2]}})
return query