Executing the following aggregation pipeline:
public void getMostLikedItems () {
UnwindOperation unwind = Aggregation.unwind(\"favoriteItems\");
From the docs.
MongoDB 3.4 deprecates the use of aggregate command without the cursor option, unless the pipeline includes the explain option. When returning aggregation results inline using the aggregate command, specify the cursor option using the default batch size cursor: {} or specify the batch size in the cursor option cursor: { batchSize: }.
You can pass batchSize
with AggregationOptions
in Spring Mongo 2.x version
Aggregation aggregation = newAggregation(unwind, group).withOptions(newAggregationOptions().cursorBatchSize(100).build());
With default batch size
Aggregation aggregation = newAggregation(unwind, group).withOptions(newAggregationOptions().cursor(new Document()).build());