# Elastisearch 5.5.1 with c# throw remote exception error please provide me the solution for this

**URL:** <https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190>\
**Category:** Elasticsearch\
**Created:** [October 17, 2017, 7:10am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190 "2017-10-17T07:10:59Z")\
**Posts on this page:** 16\
**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:** [October 17, 2017, 7:10am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/1 "2017-10-17T07:10:59Z")

</div>

Elastisearch 5.5.1 will fatch data from 10000 perfactly but above 10000 it will not fatch the data using c#, and return **remote exception error** can you please guide me the same.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 17, 2017, 9:14am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/2 "2017-10-17T09:14:36Z")

</div>

Pagination is limited by default to 10k hits. And we don't recommend changing that value.

- If you want to do deep pagination you can use the search after feature: [https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-search-after.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-search-after.html)
- If you want to extract all results, you should look at the scroll API: [https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-scroll.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-scroll.html)

---

<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:** [October 17, 2017, 2:32pm UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/3 "2017-10-17T14:32:27Z")

</div>

how to get elastic search more than 10000 record from elastic server with c# query

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 17, 2017, 3:54pm UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/4 "2017-10-17T15:54:29Z")

</div>

I think I answered. Not on `C#` though as I don't know it and its client but from an API perspective.

Did you look at scroll as I said i the dotNet client?

May be this page is relevant? [https://www.elastic.co/guide/en/elasticsearch/client/net-api/5.x/sliced-scroll-search-usage.html#\_object\_initializer\_syntax\_example\_18](https://www.elastic.co/guide/en/elasticsearch/client/net-api/5.x/sliced-scroll-search-usage.html#_object_initializer_syntax_example_18)

Or may be @Martijn_Laarman can help?

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [October 18, 2017, 2:43pm UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/5 "2017-10-18T14:43:01Z")

</div>

You can use the scroll API to do this in the .NET client. The client API also exposes an `IObservable<T>` that can be used to scroll all the documents. Something like

```
var client = new ElasticClient();

var scrollAllObservable = client.ScrollAll<MyDocument>("1m", 10, sc => sc
    .Search(s => s
        .Query(q => q
            .MatchAll()
        )
    )
);

var handle = new ManualResetEvent(false);

var scrollObserver = new ScrollAllObserver<MyDocument>(
    // on next
    r =>
    {
        // do something with the documents
        r.SearchResponse.Documents
    },
    // on exception
    e =>
    {
        handle.Set();
        throw e;
    },
    // on completion
    () => handle.Set()
);

scrollAllObservable.Subscribe(scrollObserver); 
handle.WaitOne();
```

---

<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:** [October 23, 2017, 1:19pm UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/6 "2017-10-23T13:19:08Z")

</div>

Elastic search 5.5.1 with c# Use Scroll But Does not Search Properly How To get more than 10000 record from elastic search with c# code ?

---

<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:** [October 24, 2017, 4:52am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/7 "2017-10-24T04:52:45Z")

</div>

update my elastic search version but does not work proper in .net when search more than 10000 record from elastic search generate error how to solve c# with elastic search

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 24, 2017, 7:21am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/8 "2017-10-24T07:21:13Z")

</div>

It would probably help if you share the code you wrote. Please format it using `</>` and check it's correctly formatted in the preview window.

---

<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:** [November 3, 2017, 5:08am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/9 "2017-11-03T05:08:38Z")

</div>

```
var brandResults = ConnectionToES.EsClient().Search<Nyu_ESProductListingFiltering>(s => s
                         .From(0)
                         .Size(354734)
                         .Index("ezmaal")
                         .Type("Nyu_ESProductListingFiltering")
                         .Query(q => q.Term(t => t.Field("categoryId").Value(categoryId)) && q.Term(t => t.Field("psmFiltering").Value(1)))
                         .Aggregations(a => a.Terms("saId", t => t.Field(p => p.SaId).Size(354734)).Terms("saName", t => t.Field(p => p.SaName).Size(354734))));
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 3, 2017, 5:41am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/10 "2017-11-03T05:41:42Z")

</div>

Not sure what is the error but I’m pretty sure this will cause some problems

```
Size(354734)
```

---

<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:** [November 3, 2017, 5:46am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/11 "2017-11-03T05:46:41Z")

</div>

var brandResults = ConnectionToES.EsClient().Search\<Nyu\_ESProductListingFiltering\>(s =\> s  
.From(0)  
.Size(354734)  
.Index("ezmaal")  
.Type("Nyu\_ESProductListingFiltering")  
.Query(q =\> q.Term(t =\> t.Field("categoryId").Value(categoryId)) && q.Term(t =\> t.Field("psmFiltering").Value(1)))  
.Aggregations(a =\> a.Terms("saId", t =\> t.Field(p =\> p.SaId).Size(354734)).Terms("saName", t =\> t.Field(p =\> p.SaName).Size(354734))));

**my Query is mention above , it's executes in elasticsearch1.7.2 , where it does not executes in elasticsearch5.6.3**

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 3, 2017, 5:51am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/12 "2017-11-03T05:51:04Z")

</div>

May be circuit breaker is protecting the cluster?  
Try by removing size

---

<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:** [November 3, 2017, 6:01am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/13 "2017-11-03T06:01:07Z")

</div>

when i do not set size it's giving me only 10 record as default but i need to get all record having in elasticsearch table and it is all most 354734 + records in the table

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 3, 2017, 7:05am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/14 "2017-11-03T07:05:12Z")

</div>

You have 2 size in your request.

One for the size of the resultset:

```
                     .From(0)
                     .Size(354734)

```

For this one, you must use scroll API as we already explained.

One for the Terms aggregation:

```
                     .Aggregations(a => a.Terms("saId", t => t.Field(p => p.SaId).Size(354734)).Terms("saName", t => t.Field(p => p.SaName).Size(354734))));

```

This one is more problematic as you may be won't have enough memory to run it.  
May be it can work though.  
I'd just ask myself about the use case and the way you are trying to solve it.

What are you trying to do here?

---

<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:** [November 3, 2017, 10:14am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/15 "2017-11-03T10:14:35Z")

</div>

Hi,

Thank you for your suggestions and code Snippet.

I have tried that on my project. but it seems to not working for me.  
Below is the code i have written to perform the feature.

Please do let me know what is missing.

```
 var scrollAllObservable = ConnectionToES.EsClient().ScrollAll<Nyu_ESProductListingFiltering>("1m", 10, 
                sc => sc
                .Search(s => s
                .Index("ezmaal")
                .Type("Nyu_ESProductListingFiltering")
                .From(0)
                .Size(10000)
                .Query(q => q.Term(t => t.Field("categoryId").Value(categoryId)) && q.Term(t => t.Field("psmFiltering").Value(1)))
                )
            );
```

---

<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:** [December 1, 2017, 10:14am UTC](https://discuss.elastic.co/t/elastisearch-5-5-1-with-c-throw-remote-exception-error-please-provide-me-the-solution-for-this/104190/16 "2017-12-01T10:14:45Z")

</div>

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