for example while performing aggregation the last(previous) stage gave me this documents
{
_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,
}
the next stage is $match
{
$match{
"startsFrom" : { $lte : 2},
"endsOn" : { $gte : 2},
}
}
here as after comparison with the first document the match stage results in true . so I want to skip the $match
stage for all other documents with same _id
as of the document which completed the match stage and got the result true
.
If not is there any other alternate solution to reduce the computation power consumption without changing the previous aggregation stages
NOTE :
In my case I am getting documents with same _id
more than 1000 times and that too for multiple _ids
.