Query DSL Date Range

I want to initially get all the documents from the date range and then apply grouping on user.

{
  "size": 0,
  "aggs": {
    "range": {
      "date_range": {
        "field": "@timestamp",
        "format": "MM-yyyy",
        "ranges": [
          {
            "from": "01-2015"
          }
        ]
      }
    },
    "aggs": {
      "groupby_field": {
        "terms": {
          "field": "username"
        }
      }
    }
  }
}

I get the following error:

"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed;

Can we do such a query? please let me know how can we do this?

I resolved it.
Thanks. Miss placed the "aggs" section.

{
  "size": 0,
  "aggs": {
    "range": {
      "date_range": {
        "field": "@timestamp",
        "format": "MM-yyyy",
        "ranges": [
          {
            "from": "01-2015"
          }
        ]
      },
       "aggs": {
         "groupby_field": {
            "terms": {
               "field": "username"
           }
        }
      }
    }
  }
}