# Limit results per page per field

**URL:** <https://discuss.elastic.co/t/limit-results-per-page-per-field/234249>\
**Category:** Elasticsearch\
**Created:** [May 26, 2020, 6:34am UTC](https://discuss.elastic.co/t/limit-results-per-page-per-field/234249 "2020-05-26T06:34:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adnan\_Khabbaz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adnan_khabbaz/32/69047_2.png) [@Adnan\_Khabbaz](https://discuss.elastic.co/u/Adnan_Khabbaz)\
**Post date:** [May 26, 2020, 6:34am UTC](https://discuss.elastic.co/t/limit-results-per-page-per-field/234249/1 "2020-05-26T06:34:28Z")

</div>

Hello

I have a case when I need to get only one or two documents per page that have the same field value  
I can use **collapse** for that but the problem I don't want to ignore other documents in the next pages,

So suppose documents are like this:

```auto
    [
        {
            "id": 1,
            "user_id": 1
        },
        {
            "id": 2,
            "user_id": 1
        },
        {
            "id": 3,
            "user_id": 1
        },
        {
            "id": 4,
            "user_id": 1
        },
        {
            "id": 5,
            "user_id": 2
        },
        {
            "id": 6,
            "user_id": 2
        },
        {
            "id": 7,
            "user_id": 2
        },
        {
            "id": 8,
            "user_id": 3
        },
        {
            "id": 9,
            "user_id": 3
        },
        {
            "id": 10,
            "user_id": 4
        }
    ]

```

The first page from: 0, size: 4 should be:

```auto
    [
        {
            "id": 1,
            "user_id": 1
        },
        {
            "id": 5,
            "user_id": 2
        },
        {
            "id": 8,
            "user_id": 3
        },
        {
            "id": 10,
            "user_id": 4
        }
    ]

```

The second page from: 4, size 4 should be:

```auto
    [
        {
            "id": 2,
            "user_id": 1
        },
        {
            "id": 6,
            "user_id": 2
        },
        {
            "id": 9,
            "user_id": 3
        },
        {
            "id": 3,
            "user_id": 1
        }
    ]

```

Can I do such a thing?

Thanks

---

<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:** [June 23, 2020, 6:34am UTC](https://discuss.elastic.co/t/limit-results-per-page-per-field/234249/2 "2020-06-23T06:34:34Z")

</div>

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