Backward Pagination with Elasticsearch Aggregation with Spring data Elasticsearch

Hi ,
I have aggregation Query with Composite Aggregation builder with spring data elasticsearch which provides after_key value,which return last aggregated count with That I am able do forward pagination.
Sample Query:

"aggs": {
    "my_buckets": {
      "composite": {
        "sources": [
            "price": {
              "terms": {
                "field": "price.discounted"

For backward pagination ,didn't found any proper reference.
Could anyone help,please?

I'm not too familiar with this topic, but have you looked into changing the sort of the query? If you invert the sort, I'd expect you'd get a similar result to backward pagination, but using forward pagination.

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