# After & before pagination

**URL:** <https://discuss.elastic.co/t/after-before-pagination/127495>\
**Category:** Elasticsearch\
**Created:** [April 10, 2018, 1:56pm UTC](https://discuss.elastic.co/t/after-before-pagination/127495 "2018-04-10T13:56:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrader](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@rrader](https://discuss.elastic.co/u/rrader)\
**Post date:** [April 10, 2018, 1:56pm UTC](https://discuss.elastic.co/t/after-before-pagination/127495/1 "2018-04-10T13:56:29Z")

</div>

From facebook api:  
before : This is the cursor that points to the start of the page of data that has been returned.  
after : This is the cursor that points to the end of the page of data that has been returned.

in Elasticsearch it is possible to get items after cursor, but also it is possible to get items before cursor.  
After can be done using "search\_after". How to do search before?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 10, 2018, 2:13pm UTC](https://discuss.elastic.co/t/after-before-pagination/127495/2 "2018-04-10T14:13:24Z")

</div>

You can only do that if you stored the values of `search_after` on the client side.

For anything else than deep pagination (where search after is really useful) you can just use from and size parameters.

---

<div class="post-metadata">

**Author:** ![rrader](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@rrader](https://discuss.elastic.co/u/rrader)\
**Post date:** [April 10, 2018, 2:49pm UTC](https://discuss.elastic.co/t/after-before-pagination/127495/4 "2018-04-10T14:49:13Z")

</div>

But it is possible to implement "search\_before" feature?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 10, 2018, 6:42pm UTC](https://discuss.elastic.co/t/after-before-pagination/127495/5 "2018-04-10T18:42:19Z")

</div>

I see that you opened

> <https://github.com/elastic/elasticsearch/issues/29449>

@jimczi might tell if this is doable or not.

---

<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:** [May 8, 2018, 6:42pm UTC](https://discuss.elastic.co/t/after-before-pagination/127495/6 "2018-05-08T18:42:25Z")

</div>

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