Reputation: 19
I used the allowDiskUse option with the MongoTemplate :
AggregateIterable<Document> results = mongoTemplate.getCollection("match")
.aggregate(...).allowDiskUse(true)
And still get this error :
Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in.
Is it bugged ?
Note that I use the mongo java client 3.11 and a mongo atlas M2 (v 4.2.9)
I also tried with batchSize and useCursor but it didn't work
Upvotes: 0
Views: 674
Reputation: 937
Should be like that:
AggregationResults<Document> results = mongoTemplate.aggregate(new Aggregation(aggregationOperation1, aggregationOperation2, aggregationOperation3, ....).withOptions(AggregationOptions.Builder.allowDiskUse(true)), "match", Document.class);
Of course you must define you aggregation operations.
Upvotes: 0