How to use "SQL(ROW_NUMBER())" as same as for ElasticSearch Query using C#?

Elasticsearch does not have a concept of Identity Column similar to SQL(ROW_NUMBER()). At most documents has an id which can not be incremental (like in a SQL database).

There are a few options for implementing paginations, though:

  • Using From / Size. This is the easiest to implement, but you should be aware of the deep pagination issue.
  • Using Search After. It does not have the deep pagination issue, but also has a few limitations like being unable to jump freely to random pages.
  • Using Scroll. Which is similar to Search After, but it is stateful (so should not be used for user-ended requests).