Il mio istinto era no, quindi l'ho appena provato:
> 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"
}
]
>
Sembra no, non crea automaticamente indici sui documenti secondari.