[英]How can I write DSL in python when I want to query multiple "must_not"?
我想像这样查询多个“must_not”:
{
"query":{
"bool": {
"must": { "regexp": { "DstIP": "192.168.81.*" }},
"should": [
{ "bool": {
"must_not": { "regexp": { "sourceIP": "192.168.*" }},
"must_not": { "regexp": { "sourceIP": "10.[0-255]." }},
}}
],
"minimum_should_match": 1
}
}}
这意味着我要查询 DstIP 是 192.168.81.0-255 但 sourceIP 192.168.* 和 10.* 除外。
但是字典在 python 中使用了唯一键,所以这个代码结果是:
{'query': {'bool': {'must': {'regexp': {'ciscoDstIP': '192.168.81.*'}},
'should': [{'bool': {'must_not': {'regexp': {'ciscoSrcIP': '10.[0-255].'}}}}],
'minimum_should_match': 1}}}
如何更改我的 DSL 代码以查询多个“must_not”?
您应该将查询修改为
{
"query": {
"bool": {
"must": {
"regexp": {
"DstIP": "192.168.81.*"
}
},
"must_not": [
{
"bool": {
"should": [
{
"regexp": {
"sourceIP": "192.168.*"
}
},
{
"regexp": {
"sourceIP": "10.[0-255].*"
}
}
],
"minimum_should_match": 1
}
}
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.