Is it possible to retrieve hourly buckets from timestamp field using terms aggregation and inline script using elasticsearch Rest HL client.
How can we achieve the below query using Elasticsearch Java HL Rest client ?
# script in terms aggs.
GET /pixeluidevent/uidevent/_search
{
"size": 0,
"query": {
"bool": {
"must": [ { "match": { "name": "testName" }}]
}
},
"aggs": {
"BY_DAYOFWEEK": {
"terms": {
"script": {
"lang": "painless",
"inline": "doc['eventTime'].date.hourOfDay"
}
}
}
}
}
Part of Response
"buckets": [
{
"key": "6",
"doc_count": 36821
},
{
"key": "0",
"doc_count": 34000
},
{
"key": "3",
"doc_count": 30153
},
{
"key": "2",
"doc_count": 29452
}
]
Thanks