Spring Data-MongoDb Options for aggregation method

How can i set "<strong>allowDiskUse</strong>" option in aggregation method in spring data-mongodb framework ?


The core aggregation abstraction in Spring Data MongoDB is - as the name suggests - Aggregation. It exposes a fluent API to build up a pipeline using aggregation operations.

As of version 1.6.0.M1 the Aggregation class has a ….withOptions(…) method to be used like this:

Aggregation aggregation = newAggregation(…) // build up pipeline in here .withOptions(newAggregationOptions().allowDiskUse(true).build());


I found spring data-mongodb to have limited support for the aggregation framework, however you can simply use the native library leveraging spring mongo template:


See https://github.com/mongodb/mongo-java-driver/blob/master/src/test/com/mongodb/AggregationTest.java on how to setup the List<DBObject> pipeline and how to setup allowDiskUse to true using the AggregationOptions.


  • Change Enterprise Library configuration midway in a program
  • Issue in adding Xsrf-Token in an Angular 6
  • Angular 6 does not add X-XSRF-TOKEN header to http request
  • Entity Framework One to One navigation property not loading
  • Mapping Geometry from SQLServer2008 to .NET (NHibernate
  • (Fluent) NHibernate mapping for class with calculated properties
  • What if the best way to return Option types by WCF service
  • Elmah not logging 404 (missing files / images)
  • Group By and add columns
  • Constant embedded for loop condition optimization in C++ with gcc
  • Spark dataframe to nested map
  • Setting a Sharepoint Site Theme through a Web Service?
  • How to get list of users who's birthday is today in MongoDB
  • ASP.NET MVC - Detect Time Spent on Page
  • How to override List.Add method?
  • make EF map byte array to binary instead of varbinary
  • How to concat Pandas dataframe columns
  • Compare struct to a constant in C
  • Python cosine function precision [duplicate]
  • vectorized indexing/slicing in numpy/scipy?
  • Rest Services conventions
  • Not able to aggregate on nested fields in elasticsearch
  • How to attach a node.js readable stream to a Sendgrid email?
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • Convert array of 8 bytes to signed long in C++
  • Hazelcast - OperationTimeoutException
  • Web-crawler for facebook in python
  • Akka Routing: Reply's send to router ends up as dead letters
  • RestKit - RKRequestDelegate does not exist
  • Cannot Parse HTML Data Using Android / JSOUP
  • Revoking OAuth Access Token Results in 404 Not Found
  • C# - Getting references of reference
  • -fvisibility=hidden not passed by compiler for Debug builds
  • Java static initializers and reflection
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app
  • Net Present Value in Excel for Grouped Recurring CF