Database

[{"_id":0,"matches":[{"name":"match 1","ids":[{"innerName":"1234"},{"innerName":"3"}]}]},{"_id":1,"matches":[{"name":"match 5","ids":[{"innerName":"123"},{"innerName":"1"}]},{"name":"match 5","ids":[{"innerName":"1"},{"innerName":"1234"},]},]}]

Query

db.collection.aggregate([{$match:{$expr:{$gt:[{$size:{$filter:{input:"$matches",cond:{$in:[{$last:"$$this.ids.innerName"},["1234"]]}}}},0]}}}])

Result