Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{"_id":1,"items":[{x:"one",y:"two",z:"three"},{x:"four",y:"five",z:"six"}]}]
Query
db.collection.aggregate([{$match:{_id:1}},{$project:{index:{$indexOfArray:["$items.y","two"]}}}])
Result