title: Spring - mongodb - aggregation - The 'cursor' option is required
body: <p>Executing the following aggregation pipeline:</p>
  
  <pre><code>public void getMostLikedItems () {
          UnwindOperation unwind = Aggregation.unwind("favoriteItems");
          GroupOperation group = Aggregation.group("favoriteItems").count().as("likes");
          SortOperation sort = Aggregation.sort(Sort.Direction.DESC, "likes");
  
          Aggregation aggregation = newAggregation(unwind, group, sort);
          DBObject result = mongoTemplate.aggregate(aggregation, "users", LikedItem.class).getRawResults();
  }
  </code></pre>
  
  <p>throws the following exception: </p>
  
  <pre><code>com.mongodb.MongoCommandException: Command failed with error 9: 'The 'cursor' option is required, except for aggregate with the explain argument' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "The 'cursor' option is required, except for aggregate with the explain argument", "code" : 9, "codeName" : "FailedToParse" }
  </code></pre>
  
  <p>I don't understand what is meant by cursor option here. Where should this option be configured?</p>
  
  <p><strong>EDIT</strong> Here is a sample user document</p>
  
  <pre><code>{
    "_id": "5a6df13552f42a34dcca9aa6",
    "username": "user1",
    "password": "$2a$10$p0OXq5PPa41j1e4iPcGZHuWjoKJ983sieS/ovFI.cVX5Whwj21WYi",
    "favoriteItems": [
      {
        "_id": "5a0c6b2dfd3eb67969316d6d",
        "name": "item1",
        "city": "Rabat"
      },
      {
        "_id": "5a0c680afd3eb67969316d0b",
        "name": "item2",
        "city": "Rabat"
      }
    ]
  }
  </code></pre>