I am trying to execute query on elastic search which should give me results within perticuler date range. Mapping is as follows.
{
"customertransaction" : {
"mappings" : {
"doc" : {
"properties" : {
"DTCREATED" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"STATUS" : {
"type" : "string"
},
}
I have written following query for it
SearchRequest requestQuery =
Requests.searchRequest(ConstantsValue.indexName)
.types(ConstantsValue._Type)
.source("{size:999999,"
+ "\"_source\" : "
+ "[\"DTCREATED\", \"STATUS\"]"
+ ",\"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\" } }}}}}}}");
DTCREATED field contains both date and time. I expect status count daily for from date and to date range. How can I add date range filter in this query.