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

**URL:** <https://discuss.elastic.co/t/how-to-use-sql-row-number-as-same-as-for-elasticsearch-query-using-c/97346>\
**Category:** Elasticsearch\
**Created:** [August 17, 2017, 6:38am UTC](https://discuss.elastic.co/t/how-to-use-sql-row-number-as-same-as-for-elasticsearch-query-using-c/97346 "2017-08-17T06:38:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish\_Christian](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@Ashish\_Christian](https://discuss.elastic.co/u/Ashish_Christian)\
**Post date:** [August 17, 2017, 6:38am UTC](https://discuss.elastic.co/t/how-to-use-sql-row-number-as-same-as-for-elasticsearch-query-using-c/97346/1 "2017-08-17T06:38:27Z")

</div>

We have implemented ElasticSearch in our product. Our experience with the ElasticSearch is really great and interesting. We are likely to use more and more in our website, but facing some issues in Development.  
We have checked your website and other references, but couldn't find any solution. It'll be a really great if you provide us some help into it.  
We are also implementing Pagination using ElasticSearch, but couldn't find any Identity Column in ElasticSearch same as SQL(ROW\_NUMBER()).  
So please help us, how can we get this type of result, which returns unique value in result. Primary Key concepts are not used as it is a non-relational database.

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [September 7, 2017, 10:51pm UTC](https://discuss.elastic.co/t/how-to-use-sql-row-number-as-same-as-for-elasticsearch-query-using-c/97346/2 "2017-09-07T22:51:55Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html). This is the easiest to implement, but you should be aware of the [deep pagination](https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html) issue.
- Using [Search After](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html). 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](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html). Which is similar to Search After, but it is stateful (so should not be used for user-ended requests).

---

<div class="post-metadata">

**Author:** ![Ashish\_Christian](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@Ashish\_Christian](https://discuss.elastic.co/u/Ashish_Christian)\
**Post date:** [September 8, 2017, 4:23am UTC](https://discuss.elastic.co/t/how-to-use-sql-row-number-as-same-as-for-elasticsearch-query-using-c/97346/3 "2017-09-08T04:23:54Z")

</div>

Thanks for your reply.  
We have create search functionality in E-Commerce site, and we have create one index in ElasticSearch.  
It's having 2.5L record. It takes a long time when I run a C# MVC code.  
Can you please guide me how we can get faster result using C# MVC?  
Is there any way to sync fast and easily transfer data from SQL to Elasticsearch?

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [September 8, 2017, 12:02pm UTC](https://discuss.elastic.co/t/how-to-use-sql-row-number-as-same-as-for-elasticsearch-query-using-c/97346/4 "2017-09-08T12:02:06Z")

</div>

> [@Ashish\_Christian](#):
>
> Can you please guide me how we can get faster result using C# MVC?

I am sorry but C# MVC is something that I am not familiar with.

> [@Ashish\_Christian](#):
>
> Is there any way to sync fast and easily transfer data from SQL to Elasticsearch?

You can use Logstash that will certainly save you quite some work compared to writing a custom application. But I can not guarantee it's going to be fast and easy, since this depends a lot on the context.

---

<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:** [October 6, 2017, 12:02pm UTC](https://discuss.elastic.co/t/how-to-use-sql-row-number-as-same-as-for-elasticsearch-query-using-c/97346/5 "2017-10-06T12:02:18Z")

</div>

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