【发布时间】:2015-06-09 20:15:35
【问题描述】:
这是一个包含 2 个 json 文件的单一集合。我正在搜索一个特定字段:对象中的值,并且在匹配的情况下必须返回整个子文档(集合中的特定子文档必须从以下集合中的 2 个子文档中返回)。提前致谢。
{
"clinical_study": {
"@rank": "379",
"#comment": [],
"required_header": {
"download_date": "ClinicalTrials.gov processed this data on March 18, 2015",
"link_text": "Link to the current ClinicalTrials.gov record.",
"url": "http://clinicaltrials.gov/show/NCT00000738"
},
"id_info": {
"org_study_id": "ACTG 162",
"secondary_id": "11137",
"nct_id": "NCT00000738"
},
"brief_title": "Randomized, Double-Blind, Placebo-Controlled Trial of Nimodipine for the Neurological Manifestations of HIV-1",
"official_title": "Randomized, Double-Blind, Placebo-Controlled Trial of Nimodipine for the Neurological Manifestations of HIV-1",
}
{
"clinical_study": {
"@rank": "381",
"#comment": [],
"required_header": {
"download_date": "ClinicalTrials.gov processed this data on March 18, 2015",
"link_text": "Link to the current ClinicalTrials.gov record.",
"url": "http://clinicaltrials.gov/show/NCT00001292"
},
"id_info": {
"org_study_id": "920106",
"secondary_id": "92-C-0106",
"nct_id": "NCT00001292"
},
"brief_title": "Study of Scaling Disorders and Other Inherited Skin Diseases",
"official_title": "Clinical and Genetic Studies of the Scaling Disorders and Other Selected Genodermatoses",
}
【问题讨论】:
-
您有哪个特定字段/值和哪个子文档的示例吗?
-
我用这个模式搜索过 ("clinical_study.@rank", "379");并且它被匹配但无法取回它所在的子文档。
-
在 mongo shell db.TargetCollection.find({"clinical_study.@rank": "379"}) 中执行此查询会得到什么结果
-
我得到了我搜索的相同值而不是子文档
标签: json mongodb find subdocument