How to aggregate data by hour of day regardless of day

My query is that I am not able to aggregate my data on date field as per hour of day , I want the aggregation for every hour regardless of day .

{
"size": 0,
"aggs": {
"hour": {
"date_histogram": {
"field": "date",
"interval": "hour",
"min_doc_count": 0,
"format": "hh"
}

this gives for each hour for each day which is wrong can anyone help??

Please format your code. It's ugly.

That's how it works.

I would index the hour of the day as a field within the doc and aggregate on this.

You could may be Scripted fields to extract the hour of the day but I think it will be less efficient.

Example: https://www.elastic.co/blog/kibana-4-beta-3-now-more-filtery

yes rather than scripts its better to make hour of day as field it will work but can't we do it directly on the date field , because for hour of day I have to create another property in mappings file and I am looking for doing it on the same date field , is there a way we can

can you help me to write a file script of the inline script for hour of day as I am completely new to elasticsearch