# How to use pagination in Elastic Search SQL?

**URL:** <https://discuss.elastic.co/t/how-to-use-pagination-in-elastic-search-sql/191135>\
**Category:** Elasticsearch\
**Created:** [July 18, 2019, 7:24am UTC](https://discuss.elastic.co/t/how-to-use-pagination-in-elastic-search-sql/191135 "2019-07-18T07:24:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![KrishK](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@KrishK](https://discuss.elastic.co/u/KrishK)\
**Post date:** [July 18, 2019, 7:24am UTC](https://discuss.elastic.co/t/how-to-use-pagination-in-elastic-search-sql/191135/1 "2019-07-18T07:24:53Z")

</div>

Hi

We are using elastic search SQL REST API.

POST /\_sql?format=json  
{  
"query": "SELECT \* FROM library limit 100"  
}  
If i use limit 0,100, its not working.  
And, i want to use pagination in application. is there any way to use offset in query?  
Any other way to achieve pagination functionality.

Thanks

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [July 18, 2019, 3:12pm UTC](https://discuss.elastic.co/t/how-to-use-pagination-in-elastic-search-sql/191135/2 "2019-07-18T15:12:26Z")

</div>

@KrishK Offset is not supported, but there is an issue created for that: [https://github.com/elastic/elasticsearch/issues/31549](https://github.com/elastic/elasticsearch/issues/31549).

Regarding "pagination", in SQL world there is a similar approach using cursors. Behind the scene, for ES SQL, this is implemented using the scroll API. More about cursors here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-pagination.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-pagination.html)

---

<div class="post-metadata">

**Author:** ![KrishK](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@KrishK](https://discuss.elastic.co/u/KrishK)\
**Post date:** [July 19, 2019, 7:21am UTC](https://discuss.elastic.co/t/how-to-use-pagination-in-elastic-search-sql/191135/3 "2019-07-19T07:21:04Z")

</div>

Thanks @Andrei_Stefan,

If we use cursor/Scroll API, is that possible to get results from the previous page?.

Thanks

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [July 19, 2019, 7:37am UTC](https://discuss.elastic.co/t/how-to-use-pagination-in-elastic-search-sql/191135/4 "2019-07-19T07:37:24Z")

</div>

@KrishK no, it is not possible to go back.

---

<div class="post-metadata">

**Author:** ![KrishK](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@KrishK](https://discuss.elastic.co/u/KrishK)\
**Post date:** [July 19, 2019, 7:48am UTC](https://discuss.elastic.co/t/how-to-use-pagination-in-elastic-search-sql/191135/5 "2019-07-19T07:48:49Z")

</div>

Thanks @Andrei_Stefan.

---

<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:** [August 16, 2019, 7:48am UTC](https://discuss.elastic.co/t/how-to-use-pagination-in-elastic-search-sql/191135/6 "2019-08-16T07:48:54Z")

</div>

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