Skip to content

Allow "from" parameter when using "search_after" #28068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
honzakral opened this issue Jan 3, 2018 · 2 comments
Closed

Allow "from" parameter when using "search_after" #28068

honzakral opened this issue Jan 3, 2018 · 2 comments
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories

Comments

@honzakral
Copy link
Contributor

honzakral commented Jan 3, 2018

Currently specifying a starting offset when doing a search_after search is rejected as illegal operation.

For use cases where people wish to provide their users with comfortable pagination, something like (when on page 51 out of 123): [1] [2] [3] ... [49] [50] *51* [52] [53] ... [121] [122] [123]

Currently jumping to page 49 or 53 is impossible without either retrieving too many results or specifying large value for "from". If we allowed "from" with "search_after" users could implement efficient searches to retrieve any page displayed:

  • [1], [2], [3] by using simple pagination (setting "from" to 0, 10, and 20 respectively)
  • [121], [122], [123] by reversing the sort orders for all fields, using simple pagination and then reversing the returned hits in app
  • [52], [53] by setting "search_after" to the sort value of the last hit on page 51 and using simple pagination
  • [49], [50] by reversing sort, setting "search_after" to the sort value of the first hit on page 51, using simple pagination and then reversing the returned hits in app

That way any page can be calculated cheaply and no deep pagination will be required. The largest size of hits to be sorted would be (N+1)*PAGE_SIZE where N is the number of page links displayed to either side of current page.

@honzakral honzakral added the :Search/Search Search-related issues that do not fall into other categories label Jan 3, 2018
@talevy talevy added discuss :Search/Search Search-related issues that do not fall into other categories and removed :Search/Search Search-related issues that do not fall into other categories labels Mar 19, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@jimczi
Copy link
Contributor

jimczi commented Mar 23, 2018

We discussed this with @honzakral and decided that we won't allow it in Elasticsearch. The solution is to do this pagination on the client side by requesting more documents than needed. This shouldn't be an issue because you can also limit the pages that are directly reachable from a specific position.

@jimczi jimczi closed this as completed Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

No branches or pull requests

4 participants