db.yourCollection.ensureIndex({"fruit.name":1})
Mongodb, create index on a subdocument which is a list
Domanda
Is it possible to create index on name
field in fruit
subdocument ?
{
"trees": 5,
"fruit":[{"name":"apple", "color":"red"}, {"name":"pear", "color":"green"}]
}
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow