【发布时间】:2017-02-06 20:39:56
【问题描述】:
我的文档结构如下:
{
"codeId" : 8.7628945723895E13, // long numeric value stored in scientific notation by Mongodb
"problemName" : "Hardware Problem",
"problemErrorCode" : "97695686856",
"status" : "active",
"problemDescription" : "ghdsojgnhsdjgh sdojghsdjoghdghd i0dhgjodshgddsgsdsdfghsdfg",
"subProblems" : [
{
"codeId" : 8.76289457238896E14,
"problemName" : "Some problem",
"problemErrorCode" : "57790389503490249640",
"problemDescription" : "This is edited",
"status" : "active",
"_id" : ObjectId("589476eeae39b20b1c15535b")
},
...
]
}
我有一个搜索字段,应该按codeId 搜索,它基本上在搜索字段中充当parentCodeID,如下所示
现在,除了parentIdCode,我还想搜索codeId、problemCode、problemName 和problemDescription。
如何使用正则表达式搜索查询子模块,同时使用"$or" 子句等标记某些父字段以实现此目的?
【问题讨论】:
标签: mongodb mongoose mongodb-query