I want to get only one record per hours in a date range. For Example, If I want to get the data's between the days (28-08-2018 - 15-09-2018) there are almost 10000 records, but I want to filter the result to show only one record per hour, So I am using aggregation with date_histogram, and I can see only one record per hour
{
"size" : 0,
"query": {
"bool": {
"must": [
{
"range": {
"createdtime": {
"gte": "1535201500000",
"lte": "1536756706000",
"boost": 2.0
}
}
},
{
"match": {
"gen": 1
}
},
{
"match": {
"Mid": 350404
}
}
]
}
},
"aggregations" : {
"runtime" : {
"date_histogram" : {
"field" : "createdtime",
"interval" : "1H",
"min_doc_count": 1
},"aggs": {
"tops": {
"top_hits": {
"size": 1
}
}
}
}
}
}
Here the problem is I want to use pagination to show these results as I know there is no way to use size and from on aggregation query as of now, I want to know is there any other way to get only one records in an hour