Elasticsearch date range query using java api

I am using elasticsearch 1.5.2 and written query to get status count for last x days.

SearchRequest requestQuery =
 Requests.searchRequest(ConstantsValue.indexName)
.types(ConstantsValue._Type)
.source("{size:999999,"
 + "\"_source\" : "
 + "[\"DTCREATED\", \"STATUS\"]"
 +", \"query\": {"
 +" \"filtered\": {"
 +" \"filter\": {"
 + "\"range\": { \"DTCREATED\": { \"gte\": \"now-30d/d\" }}"
 +"}}}"
 + ",\"aggs\": "
 + "{\"group_by_STATUS\": {\"terms\": {\"field\": \"STATUS\"},"
 + "\"aggs\" : "
 + "{\"group_by_DATE\" : {\"date_histogram\" : "
 + "{\"field\" : \"DTCREATED\", \"interval\" : \"day\","
 + "\"format\" : \"yyyy-MM-dd\" },"
 + "\"aggs\" : "
 + "{\"grades_count\" : { \"value_count\" : { \"field\" : \"STATUS\" } }}}}}}}");

Now I want to use date range like data should be fetched within x to y date. How can I change above query to get expected result. DTCREATED field contains both date and time.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.