i have below collections with document count division - 30,
category - 248
productgroup - 1402
product - 60000
for example i given below dat
You should use $skip and $limit to avoid this error. why getting this error ? you have to read @Alex comment link.
db.products.aggregate([
{$skip:0},{$limit: 1000},
{$lookup:{from:"productgroups", localField:"productgroupid", foreignField:"productgroupid", as:"group"}},
{$lookup:{from:"category", localField:"categoryid", foreignField:"categoryid", as:"category"}},
{$lookup:{from:"divisions", localField:"divisionid", foreignField:"divisionid", as:"division"}},
{$project: {productpoint:1,productname:1,productcode:1,productid:1,group: { $arrayElemAt: [ "$group", 0 ]},
category: { $arrayElemAt: [ "$category", 0 ]}, division: { $arrayElemAt: [ "$division", 0 ]} }}
]);
{$skip:0},{$limit: 1000}
// for initial and then for next time should skip: 1000, limit:1000 and so on. you may get it from request or by using loop or as you implement.