db.yourCollection.ensureIndex({"fruit.name":1})
Mongodb, create index on a subdocument which is a list
Question
Is it possible to create index on name
field in fruit
subdocument ?
{
"trees": 5,
"fruit":[{"name":"apple", "color":"red"}, {"name":"pear", "color":"green"}]
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow