Description
Starting with MongoDB 5.0.4, db.serverStatus() adds counters for match operators.
The entry for 'metrics.operatorCounters.match' looks like:
"match": {
|
"$all": 0,
|
...
|
"$or": 4249,
|
"$regex": 21,
|
"$sampleRate": 0,
|
"$size": 0,
|
"$text": 0,
|
"$type": 7,
|
"$where": 0
|
}
|
The problem is with the "$regex" field that is rejected by the BSON library.
Here is short program showing the failure.
#!python
|
|
# works
|
regex_str_doc = """
|
{
|
"$regex": "10"
|
}
|
"""
|
|
# fails
|
regex_int_doc = """
|
{
|
"$regex": 10
|
}
|
"""
|
|
import bson.json_util
|
import pymongo
|
|
o = bson.json_util.loads(regex_str_doc) # works
|
#o = bson.json_util.loads(regex_int_doc) # fails
|