骨料在mongodb,而不是pymongo
获取以下错误:
提高操作范围(errmsg,代码,响应,max_wire_version) pymongo.errors.operationFailure:不记忆,完整错误:{'aperative time':timestamp(1650998892,1),'ok':0.0,'errmsg':'of norme :'jsinterPreterFailure','$ clustertime':{'clusterTime':timestamp(1650998892,1),'signature':{'hash':b'z \ x93l \ x033 \ x033 \ xe6 \ xe6 \ x82 XAE \ XCE \ X0C \ X17','KEYID':7031229705458024454}}}}}}
以下查询确实可以在Pymongo工作。
aggregate_pipeline = [
{
'$project': {
'data': "$$ROOT"
}
},
{
"$project": {
"flattenKeys": {
"$function": {
"body": "function flatten(dataList, keysToHandle){while(keysToHandle.length){origKeyData = keysToHandle.shift();for (const newKey of Object.keys(origKeyData.objData)){keysToHandle.push({objData:origKeyData.objData[newKey],keyData:`${origKeyData.keyData}.${newKey}`});dataList.push(`${origKeyData.keyData}.${newKey}`);}}return dataList}",
"args": [
[],
[
{
'objData': "$data",
'keyData': "data"
}
]
],
"lang": "js"
}
}
}
},
{
'$project': {
'matchingKeys': {
'$filter': {
'input': "$flattenKeys",
'as': "item",
'cond': {
'$regexMatch': {
'input': "$$item",
'regex': fields
}
}
}
}
}
}]
result = collection.aggregate(aggregate_pipeline, allowDiskUse=True)
print(list(result))
Getting the following error:
raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: Out of memory, full error: {'operationTime': Timestamp(1650998892, 1), 'ok': 0.0, 'errmsg': 'Out of memory', 'code': 139, 'codeName': 'JSInterpreterFailure', '$clusterTime': {'clusterTime': Timestamp(1650998892, 1), 'signature': {'hash': b'Z\x93L\x033\xe6 \x82|\x82wA\xf3Bh\xe7\xae\xce\x0c\x17', 'keyId': 7031229705458024454}}}
The following query does to work in PyMongo.
aggregate_pipeline = [
{
'$project': {
'data': "$ROOT"
}
},
{
"$project": {
"flattenKeys": {
"$function": {
"body": "function flatten(dataList, keysToHandle){while(keysToHandle.length){origKeyData = keysToHandle.shift();for (const newKey of Object.keys(origKeyData.objData)){keysToHandle.push({objData:origKeyData.objData[newKey],keyData:`${origKeyData.keyData}.${newKey}`});dataList.push(`${origKeyData.keyData}.${newKey}`);}}return dataList}",
"args": [
[],
[
{
'objData': "$data",
'keyData': "data"
}
]
],
"lang": "js"
}
}
}
},
{
'$project': {
'matchingKeys': {
'$filter': {
'input': "$flattenKeys",
'as': "item",
'cond': {
'$regexMatch': {
'input': "$item",
'regex': fields
}
}
}
}
}
}]
result = collection.aggregate(aggregate_pipeline, allowDiskUse=True)
print(list(result))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论