从文档中。
MongoDB 3.4不赞成使用不带光标的聚合命令
选项,除非管道包含explain选项。什么时候
使用aggregate命令内联返回聚合结果,
使用默认的批大小游标指定游标选项:{}或
在光标选项光标中指定批次大小:{批次大小:
}.
你可以通过
batchSize
具有
AggregationOptions
Jongo骨料法。
AggregationOptions options = AggregationOptions.builder().options.
batchSize(100).
outputMode(AggregationOptions.OutputMode.CURSOR).build();
collection.aggregate("{$match:{componentType:'Endpoint'}}").options(options).as(MongoTestClass.class).iterator();
使用默认批量大小
AggregationOptions options = AggregationOptions.builder().options.
outputMode(AggregationOptions.OutputMode.CURSOR).build();
或
AggregationOptions options = AggregationOptions.builder().build();
collection.aggregate("{$match:{componentType:'Endpoint'}}").options(options).as(MongoTestClass.class).iterator();