# Elasticsearch pagenation spillage

**URL:** <https://discuss.elastic.co/t/elasticsearch-pagenation-spillage/26289>\
**Category:** Elasticsearch\
**Created:** [July 25, 2015, 2:51pm UTC](https://discuss.elastic.co/t/elasticsearch-pagenation-spillage/26289 "2015-07-25T14:51:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lorenzo](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@Lorenzo](https://discuss.elastic.co/u/Lorenzo)\
**Post date:** [July 25, 2015, 2:51pm UTC](https://discuss.elastic.co/t/elasticsearch-pagenation-spillage/26289/1 "2015-07-25T14:51:17Z")

</div>

I run this query with a php client:

```
$params["body"] = [
            "from" => $page,
            "query" => ["filtered" => ["filter" => ["bool" => [
                            "must" => [
                                ["term" => ["user" => $userId]],
                                ["term" => ["activitySeen" => false]]
                            ]
                        ]
                    ]
                ]
            ],
            "size" => 5,
        ];

```

I have a total of 3 documents that should be returned. Searching with $page = 0 returns 3 documents as expected.

However, searching with $page = 1 returns 2 documents and with $page =  
2 returns 1 document and the search with $page = 3 returns 0 documents.

Does anybody know what might be the issue?

If I play with page sizes the spillage is still there: last  
legitimate page of values is spilled on to the next page with one less  
value!

I'm testing it either on one or two nodes with 3 primary and 1 replica shards. ES 1.7.0 and official PHP client.

Thanks.

**I found the problem: the from is an offset and not page number!**

---

<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 5, 2017, 11:59pm UTC](https://discuss.elastic.co/t/elasticsearch-pagenation-spillage/26289/2 "2017-07-05T23:59:00Z")

</div>


