title: Elastic search date range aggregation
body: <p>I have a Json Data </p>
  
  <pre><code>"hits": [
           {
              "_index": "outboxprov1",
              "_type": "deleted-connector",
              "_id": "AHkuN5_iRGO-R5dtaOvz6w",
              "_score": 1,
              "_source": {
                 "user_id": "1a9d05586a8dc3f29b4c8147997391f9",
                 "deleted_date": "2014-08-02T04:55:04.509Z"
              }
           },
           {
              "_index": "outboxprov1",
              "_type": "deleted-connector",
              "_id": "Busk7MDFQ4emtL3x5AQyZA",
              "_score": 1,
              "_source": {
                 "user_id": "1a9d05586a8dc3f29b4c8147997391f9",
                 "deleted_date": "2014-08-02T04:58:31.440Z"
              }
           },
           {
              "_index": "outboxprov1",
              "_type": "deleted-connector",
              "_id": "4AN0zKe9SaSF1trz1IixfA",
              "_score": 1,
              "_source": {
                 "user_id": "1a9d05586a8dc3f29b4c8147997391f9",
                 "deleted_date": "2014-07-02T04:53:07.010Z"
              }
           }
  ]
  </code></pre>
  
  <p>Am trying to write aggregation query which will find records in particular "deleted_date" range. 
  This is my query </p>
  
  <pre><code>{
    "size": 0,
    "query": {
      "match_all": {}
    },
    "aggs": {
      "daily_team": {
        "date_range": {
          "field": "deleted_date",
           "format": "YYYY-MM-DD",
          "ranges": [
            {
              "from": "2014-08-02"
            },
            {
              "to": "2014-08-02"
            }
          ]
        },
        "aggs": {
          "daily_team_count": {
            "terms": {
              "field": "user_id"
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>My problem is am not getting correct number of records in particular date range. When i put any date am getting some doc_count number. Am new to elastic search. Am not sure is it the way to write range aggregation query. Please help me to solve this issue. </p>