I have an interesting problem at work. We have a document structure like this:
{
"q" : "c1179beb-2db4-4052-b10d-f0c1332436f3",
"ssm" : {
"0168edb0-c25d-42ba-ba6d-918c4f61f6e1" : {
"xas" : [],
"dob" : ISODate("2001-01-01T00:00:00.000Z"),
"we" : "bow-bq",
"gndr" : "M",
"lcd" : ISODate("2014-02-21T09:00:04.575Z"),
"re" : "tyjhgj",
"s" : "0168edb0-c25d-42ba-ba6d-918c4f61f6e1",
"scsv" : "testdata",
"sg" : {
"grd" : "FOUR",
"gdn" : "4"
},
"sno" : "100000002",
"sss" : "Ha",
"stst" : {
"tk" : "226",
"tn" : "That"
},
"tsd" : ISODate("2014-02-21T08:35:51.075Z")
},
"016e48fa-5c24-4fd5-b078-5333991de013" : {
"xas" : [],
"dob" : ISODate("2001-01-01T00:00:00.000Z"),
"we" : "dsgsdf",
"gndr" : "M",
"lcd" : ISODate("2014-02-21T09:04:11.995Z"),
"lia" : 53,
"re" : "ghjghjgh",
"s" : "016e48fa-5c24-4fd5-b078-5333991de013",
"scsv" : "testdata",
"sg" : {
"grd" : "FOUR",
"gdn" : "4"
},
"sno" : "100000029",
"sss" : "Ha",
"stst" : {
"tk" : "86",
"tn" : "That"
},
"tsd" : ISODate("2014-02-21T08:50:55.821Z")
},
"076fc7ab-264b-4814-9f3a-db9f8222d02f" : {
"xas" : [],
"dob" : ISODate("2001-01-01T00:00:00.000Z"),
"we" : "hjhyyio",
"gndr" : "M",
"lcd" : ISODate("2014-02-21T09:04:58.299Z"),
"lia" : 53,
"re" : "qsdrfg",
"s" : "076fc7ab-264b-4814-9f3a-db9f8222d02f",
"scsv" : "testdata",
"sg" : {
"grd" : "FOUR",
"gdn" : "4"
},
"sno" : "100000003",
"sss" : "HA",
"stst" : {
"tk" : "161",
"tn" : "That"
},
"tsd" : ISODate("2014-02-21T08:52:04.471Z")
},
"try" : "34534",
"jyu" : ISODate("2014-03-01T07:59:59.000Z"),
"poij" : ISODate("2014-01-08T08:00:00.000Z")
}
}
Obviously this is data that has been edited to hide the source but the structure is the same.
I am trying to write a query that will search on the "s" field of the sub-documents contained in the sub-document "ssm".
I have tried using $elementmatch as well as using standard dot notation. The issue I am running into is that the "ssm" field is more of a sub-collection than a sub-document. I'm a little lost and am hoping for a few suggestions.
Reading the Mongo documentation I can't seem to find any way to query sub-collections. Google shows me plenty of ways to query an ARRAY of sud-documents but that is not what I'm dealing with here.
Please Help!