How to support pagination in aggregation

{
"aggs": {
"thread": {
"terms": {
"field": "session_id"
}
}
}
}

i want to add pagination in field session_id how can it?

Please have a look at composite aggregations, aggs are limited to 1 request, with composite you can page agg results.

Can you give me a example? and please also give me solution if any possibility for adding limit inside the aggregation.

Please have a look at the provided link, it has tons of examples. If you have a specific question that is not answered in the docs, I happily help.

I do not understand what you mean with "adding limit inside aggregation", best if you can give an example and/or elaborate on what you want to do.

{
"size": "0",
"query": {
"match_all": {}
}
"aggs": {
"analytics": {
"filter": {
"term": {
"event_type": "analytics"
}
},
"aggs": {
"thread": {
"terms": {
"field": "session_id",
},
"aggs": {
"tops": {
"top_hits": {
"sort": [
{
"created_at": {
"order": "desc"
}
}
],
"size": 1
}
}
}
}
}
}
}

Here in my above example i filter by event_type(analytics) and group by session_id. sort according to created_at. so in above example i get the latest information of each session. like if we have 50 session then according to above my example it gives latest information of 50 session.

but, my target is support pagination in session like i pass 1 to 10 value then it gives only latest information of 1 to 10 session. if i pass the value 11 to 20 then it gives only latest information of 11 to 20 session.

How many sessions in total do you expect?
When you say sessions 1 to 10, 11 to 20, ... What order do you expect? Note that new incoming data might change the order between 2 search requests.

Depending on the size you have several options.