Announcement Announcement Module
Collapse
No announcement yet.
Mongo error when use aggregation, Sort exceeded memory limit Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mongo error when use aggregation, Sort exceeded memory limit

    Hi, i use aggregation for group data in mongo with the follow code:

    Code:
            AggregationOperation criterio =
                    Aggregation.match(Criteria.where("remitente").exists(true).andOperator(
                            Criteria.where("fecha").lt(f2),
                            Criteria.where("fecha").gte(f1)
                    ));
    
            AggregationOperation grupo = Aggregation.group("fechaSimple").count().as("total");
            AggregationOperation orden = Aggregation.sort(Sort.Direction.ASC, "fecha");
            Aggregation aggregation = Aggregation.newAggregation(criterio, orden, grupo);
    
            AggregationResults<AgFechas> result = this.mongoTemplate.aggregate(aggregation, "envios", AgFechas.class);
            List<AgFechas> agFechas = result.getMappedResults();

    But when I run it gives me the error:

    Code:
    org.springframework.dao.InvalidDataAccessApiUsageException: Command execution failed:  Error [exception: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.], Command = { "aggregate" : "envios" , "pipeline" : [ { "$match" : { "remitente" : { "$exists" : true} , "$and" : [ { "fecha" : { "$lt" : { "$date" : "2014-08-27T16:04:45.000Z"}}} , { "fecha" : { "$gte" : { "$date" : "2012-12-31T23:00:40.000Z"}}}]}} , { "$sort" : { "fecha" : 1}} , { "$group" : { "_id" : "$fechaSimple" , "total" : { "$sum" : 1}}}]}; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "localhost/127.0.0.1:27017" , "errmsg" : "exception: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in." , "code" : 16819 , "ok" : 0.0}
        at org.springframework.data.mongodb.core.MongoTemplate.handleCommandError(MongoTemplate.java:1846)
        at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1329)
        at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1311)
    ...
    How do I fix the problem?

    Thanks!

  • #2
    This is currently not possible with our aggregation framework support. We filed: https://jira.spring.io/browse/DATAMONGO-960 to track this issue.

    Please, move your question to the StackOverflow - we are going to close this forum soon and rely on SO.
    We need to clean this forum (old unanswered question) before close it.

    Thanks for understanding
    Last edited by thomas.darimont; Jun 24th, 2014, 04:10 AM.

    Comment

    Working...
    X