# Pagination with field collapse

**URL:** <https://discuss.elastic.co/t/pagination-with-field-collapse/274863>\
**Category:** Elasticsearch\
**Created:** [June 3, 2021, 11:27am UTC](https://discuss.elastic.co/t/pagination-with-field-collapse/274863 "2021-06-03T11:27:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![schawla](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@schawla](https://discuss.elastic.co/u/schawla)\
**Post date:** [June 3, 2021, 11:27am UTC](https://discuss.elastic.co/t/pagination-with-field-collapse/274863/1 "2021-06-03T11:27:01Z")

</div>

How is it possible to implement pagination in elastic search when we are field collapsing and returning top 5 results from each index.

```auto
GET /my-index-000001/_search
{
  "query": {
    "match": {
      "message": "GET /search"
    }
  },
  "collapse": {
    "field": "user.type",                       
    "inner_hits": {
      "name": "top5",                  
      "size": 5                       
    },
  }
}

```

In a normal search query it easily done using Size and From attributes in the search request.  
But how does it work when someone is using field collapsing and we want to skip first n results and return next 5.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 1, 2021, 11:27am UTC](https://discuss.elastic.co/t/pagination-with-field-collapse/274863/2 "2021-07-01T11:27:45Z")

</div>

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