title: Getting count and grouping by date range in elastic search
body: <p>Is there a way to get the count of rows and group them by hour, day or month.</p>
  
  <p>For instance, assume I have the messages </p>
  
  <pre><code>_source{
  "timestamp":"2013-10-01T12:30:25.421Z",
  "amount":200
  }
  _source{
  "timestamp":"2013-10-01T12:35:25.421Z",
  "amount":300
  }
  _source{
  "timestamp":"2013-10-02T13:53:25.421Z",
  "amount":100
  }
  _source{
  "timestamp":"2013-10-03T15:53:25.421Z",
  "amount":400
  }
  </code></pre>
  
  <p>Is there a way to get something alone the lines of {date, sum} (not necessarily in this format, just wondering if there is any way i can achieve this)</p>
  
  <pre><code>{
  {"2013-10-01T12:00:00.000Z", 500},
  {"2013-10-02T13:00:00.000Z", 100},
  {"2013-10-03T15:00:00.000Z", 400}
  }
  </code></pre>
  
  <p>Thank you</p>