Domanda

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

{                                                                               
    "trees": 5,
    "fruit":[{"name":"apple", "color":"red"}, {"name":"pear", "color":"green"}]
}
È stato utile?

Soluzione

db.yourCollection.ensureIndex({"fruit.name":1})
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top