从文档。
MongoDB 3.4不建议使用不带游标选项的聚合命令,除非管道包括解释选项。使用聚合命令以内联方式返回聚合结果时,请使用默认批处理大小游标:{}指定游标选项,或在游标选项游标:{batchSize:}中指定批处理大小。
你可以通过batchSize
与AggregationOptions
在春季蒙戈2.x版
Aggregation aggregation = newAggregation(unwind, group).withOptions(newAggregationOptions().cursorBatchSize(100).build());
使用默认批次大小
Aggregation aggregation = newAggregation(unwind, group).withOptions(newAggregationOptions().cursor(new Document()).build());