Vra

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

{                                                                               
    "trees": 5,
    "fruit":[{"name":"apple", "color":"red"}, {"name":"pear", "color":"green"}]
}
Was dit nuttig?

Oplossing

db.yourCollection.ensureIndex({"fruit.name":1})
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top