Field Collapsing & Pagination

I just want to know how pagination works with collapsing.
I have below index data:

    {'departmentNo': 1, 'departmentName': 'Food', 'departmentLoc': "I1", "departmentScore": "5", "employeeid" : 1, "employeeName": "vijay", ...}
    {'departmentNo': 1, 'departmentName': 'Food', 'departmentLoc': "I1", "departmentScore": "5", "employeeid" : 2, "employeeName": "rathod", ...}
    {'departmentNo': 2, 'departmentName': 'Non-Food', 'departmentLoc': "I2", "departmentScore": "6", "employeeid" : 3, "employeeName": "ajay", ...}
    {'departmentNo': 2, 'departmentName': 'Non-Food', 'departmentLoc': "I2", "departmentScore": "6", "employeeid" : 4, "employeeName": "kamal", ...}
    {'departmentNo': 1, 'departmentName': 'Food', 'departmentLoc': "I1", "departmentScore": "5", "employeeid" : 5, "employeeName": "rahul", ...}

I want to get below Output with pagination

{'departmentNo': 1, 'departmentName': 'Food', 'departmentLoc': "I1", "departmentScore": "5", "employeeid" : 1, "employeeName": "vijay", ...}
{'departmentNo': 2, 'departmentName': 'Non-Food', 'departmentLoc': "I2", "departmentScore": "6", "employeeid" : 3, "employeeName": "ajay", ...}

So I have used below query:

{
  "query": { ... },
  "from": 0,
  "size": 5,
  "collapse": {
    "field": "departmentNo"
  }
}

So for first 5 , it is giving correct results. when I do from =1, size =5 then it is giving wrong results.

Hey,

instead of claiming the return of 'wrong' results, it would help if you explain what are you expecting to be returned and if you explain what you are seeing returned and what are the differences. Not everyone has the same context in mind than you, when talking about field collapsing.

Also, fully reproducible examples would help a lot to understand your issue instead of just snippets. This way, noone will ever try to reproduce your problem.

--Alex