# Search with pagination

**URL:** <https://discuss.elastic.co/t/search-with-pagination/158384>\
**Category:** Elasticsearch\
**Created:** [November 27, 2018, 4:46pm UTC](https://discuss.elastic.co/t/search-with-pagination/158384 "2018-11-27T16:46:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pablo\_rufat](https://avatars.discourse-cdn.com/v4/letter/p/f4b2a3/32.png) [@pablo\_rufat](https://discuss.elastic.co/u/pablo_rufat)\
**Post date:** [November 27, 2018, 4:46pm UTC](https://discuss.elastic.co/t/search-with-pagination/158384/1 "2018-11-27T16:46:04Z")

</div>

Hi!

I'm trying to find a way to combine pagination and search over a resultset of an aggregation.

I have a sorted aggregation that returns 20 buckets per page (I'm doing it with composite aggregation and after attribute, but I've tryed truncating with bucket\_sort too).

Now I want to search by bucket key and get as result the searched bucket and the next 19 buckets. The tricky part is that I need (or I think I need) the position of the searched bucket within the sortd aggregation to update the pagination info (something like "showing from xx to [xx+20] of [total]", and enable or disable the navigations buttons).

I think the problem could be solved knowing the position of each bucket when sorted by some field, but I can't find anywhere if this is possible.

Any idea on how to solve it?

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:** [December 25, 2018, 4:46pm UTC](https://discuss.elastic.co/t/search-with-pagination/158384/2 "2018-12-25T16:46:11Z")

</div>

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