Sort before pagination

Hey I am trying to sort and paginate the result simultaneously, but I am not getting the expected result.

NOTE: we are using 6.1 version
Example:

data = [
{
level : 0
time: some date
... other fields
}  ,
{
level: 1
time: some date
}.... and so on
]

// There are multiple data for each level

Here is my Elasticsearch sort query

sort = [
     {level: {order: 'asc'}},
    {time: {order: 'asc'}}
]

I have set the limit: 20 and from: 0
Result:
I get the sort result with some level: 0 and some level:1 for the first page
Move to next page same result as above some level: 0 and some level:1

Expected Result:
Should get all the level:0 data first and then other levels, even through the pages
-> Example
Let say I have 40 level:0 data, 40 level:1 data and so on.
So the expected result should be:
As we have set the limit to 20 so First two pages should be level:0 data then next two pages should level: 1 data and so on.

Welcome to community Rushil,
Have you looked at PIT (point in time) feature in es.

Kindly see if this helps:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.