Database

[{docs:[{_id:ObjectId("662a416201ca2363543b6644"),name:"location-1",startsFrom:2,endsOn:5},{_id:ObjectId("662a416201ca2363543b6644"),name:"location-1",startsFrom:1,endsOn:3},{_id:ObjectId("662a416201ca2363543b6644"),name:"location-1",startsFrom:2,endsOn:4}]},{docs:[{_id:ObjectId("662a416201ca2363543b7777"),name:"location-3",startsFrom:2,endsOn:4},{_id:ObjectId("662a416201ca2363543b7777"),name:"location-3",startsFrom:1,endsOn:3}]}]

Query

db.collection.aggregate([/** put a sort before this*/{$set:{first_match:{$reduce:{input:"$docs",initialValue:{},in:{$cond:{/** check if a match has already been*/if:{$ne:["$$value",{}]},/** return the matched sub-doc, don't check any more*/then:"$$value",/** no matched sub-doc, so check this one*/else:{$cond:{if:{$and:[{$lte:["$$this.startsFrom",2]},{$gte:["$$this.endsOn",2]}]},/** return this sub-doc if it's a match*/then:"$$this",/** otherwise return an empty object*/else:{}}}}}}}}},{$replaceWith:"$first_match"}])

Result