I have this MongoDB query in Python.
results = collection.aggregate([
{
"$match": {
"monitor": {
"$in": [/\/tcp/,/\/http$/,/\/https_443$/,/\/https$/,/\/http_head_f5$/,/\/https_head_f5$/,/\/icmp$/]
}
}
},
{
"$project": {
"_id": 0,
"name": 1,
"partition": 1,
"fullPath": 1,
"type": 1,
"loadBalancingMode": 1,
"monitor": 1,
"f5ip": 1,
"poolstatus": 1
}}
])
I am having difficulty turning this line into a valid Python syntax
"$in": [/\/tcp/,/\/http$/,/\/https_443$/,/\/https$/,/\/http_head_f5$/,/\/https_head_f5$/,/\/icmp$/]
I tried "$regex" option but we cannot use $regex inside $in. I also tried converting the array elements into the string and escaping the slashes as shown below.
"$in": ["\/\/tcp\/","\/\/http$/"]
I want to know how I can turn that MongoDB query into valid python syntax and receive the same results using PyMongo.