How to get a previous page from elasticsearch using search_after?

This query looks very complicated. Generally, you can use search_after but reverse the sort order to get the page before. See also a similar discussion on GitHub: https://github.com/elastic/elasticsearch/issues/24364