Mijn instinct was nee, dus ik probeerde het gewoon:
> db.foo.find()
> db.foo.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "foo.foo"
}
]
> db.foo.insert({
... _id: "joe",
... name: "Joe Bookreader",
... addresses: [
... {
... _id: "someid1",
... street: "123 Fake Street",
... city: "Faketon",
... state: "MA",
... zip: "12345"
... },
... {
... _id: "someid2",
... street: "1 Some Other Street",
... city: "Boston",
... state: "MA",
... zip: "12345"
... }
... ]
... })
WriteResult({ "nInserted" : 1 })
> db.foo.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "foo.foo"
}
]
>
Het lijkt erop dat het niet automatisch indexen maakt op subdocumenten.