Thursday, 1 September 2016

MongoDB aggregation result exceeds maximum document size (16MB) ~ gniithelp

MongoDB aggregation result exceeds maximum document size (16MB)
 
{
    "errmsg" : "exception: aggregation result exceeds maximum document size (16MB)",
    "code" : 16389,
    "ok" : 0
}

Solution : allowDiskUse to true or limit critera to max elements


Example

AggregationOptions aggregationOptions = new AggregationOptions(true,false,null);
Aggregation aggregation = newAggregation(
 match(criteria),  
 limit(10),
 sort(Sort.Direction.ASC,  "OrderSubmissionDate")
).withOptions(aggregationOptions);

No comments:

Post a Comment