私の本能はノーだったので、私はそれを試しました:
> 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"
}
]
>
いいえ、サブドキュメントにインデックスを自動的に作成しないようです。