Getting documents on per day and per hour basis in elasticsearch?

ES 2.4.0

i have data in the format like this:

{"text": "cp","created_at": "2017-01-27T11:30:36.000Z"} --FRIDAY
{"text": "cpk","created_at": "2017-01-26T00:30:36.000Z"} --Thursday
{"text": "sai","created_at": "2017-01-24T18:30:36.000Z"} --Tuesday
{"text": "pavan","created_at": "2017-01-24T09:30:36.000Z"} --Tuesday

when i used the aggregation on this i am getting like this

"aggregations": {
"byDays": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Thursday",
"doc_count": 2,
"byHours": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "04",
"doc_count": 1
},
{
"key": "06",
"doc_count": 1
}
]
}
},
{
"key": "Friday",
"doc_count": 1,
"byHours": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "17",
"doc_count": 1
}
]
}
},
{
"key": "Tuesday",
"doc_count": 1,
"byHours": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "15",
"doc_count": 1
}
]
}
},
{
"key": "Wednesday",
"doc_count": 1,
"byHours": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "00",
"doc_count": 1
}
]
}
}
]
}
}
}

i am a groovy script consists of following code:
Date date = new Date(doc[date_field].value);
date.format(format);

My problem is there is no matching between the input documents time and day with output results?

In my input data there are two documents on tuesday but in my output it is on thrusday with different hours.

Can anyone help me in solving this?

Do i need to change the timezone or something??

Thanks

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