Pregunta

Is it possible to create index on name field in fruit subdocument ?

{                                                                               
    "trees": 5,
    "fruit":[{"name":"apple", "color":"red"}, {"name":"pear", "color":"green"}]
}
¿Fue útil?

Solución

db.yourCollection.ensureIndex({"fruit.name":1})
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top