I have data in ES as:
"hits": {
"total": 177,
"max_score": 1,
"hits": [
{
"_id": "random_id_1",
"_score": 1,
"_source": {
"title": "Find series",
"description": "some random text",
"createdAt": 1527848716000,
"category": [
"STARS"
],
"updatedAt": 1527848716000
}
},
{
"_id": "random_id_2",
"_score": 1,
"_source": {
"title": "Find series 2",
"description": "some random text 2",
"createdAt": 1527848716001,
"category": [
"SOLARS"
],
"updatedAt": 1527848716001
}
}
]
What is wanted is to display n data from each category. For which query formed using aggregation as:
{
"size": 0,
"aggs": {
"summary": {
"terms": {
"field": "category"
},
"aggs": {
"summary": {
"top_hits": {
"sort": [
{
"createdAt": "desc"
}
],
"size": 100
}
}
}
}
}
}
But what i am unable to get is pagination. If i use from under nested aggregation, i can have pagination, but if data gets updated, from will be of no use. What i want is keyset pagination based on _id, but am not able to figure out how to achieve the same? Any help in here. Thanks