# Count in C# NEST for ES 5.5

**URL:** https://discuss.elastic.co/t/count-in-c-nest-for-es-5-5/98525
**Category:** Elasticsearch
**Created:** [August 28, 2017, 9:27am UTC](https://discuss.elastic.co/t/count-in-c-nest-for-es-5-5/98525 "2017-08-28T09:27:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mwdoerner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mwdoerner/32/21564_2.png) [@mwdoerner](https://discuss.elastic.co/u/mwdoerner)
#### Post date: [August 28, 2017, 9:27am UTC](https://discuss.elastic.co/t/count-in-c-nest-for-es-5-5/98525/1 "2017-08-28T09:27:51Z")

</div>

Hi,

I'm writing a simple C# app that uses the NEST client for retrieving data from a local Elasticsearch instance. I have a small problem trying to get the number of all indexed (over all indices) documents. There is some documentation for the count() method for Elasticsearch 1.x here:

[https://www.elastic.co/guide/en/elasticsearch/client/net-api/1.x/count.html](https://www.elastic.co/guide/en/elasticsearch/client/net-api/1.x/count.html)

but the same site is not available for the current version, and also the simple .count() call doesn't work anymore as it requires some parameters.

I tried the search functionality on this forum because I think that this topic was somewhere discussed before, but all I've found were some count issues for nested documents - not a simple count() for indexed documents (without nested docs).

Could you please explain how to get the number of indexed documents in the current NEST client version?

Greetings  
Martin

---

<div class="post-metadata">

### Author: ![mwdoerner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mwdoerner/32/21564_2.png) [@mwdoerner](https://discuss.elastic.co/u/mwdoerner)
#### Post date: [August 28, 2017, 11:31am UTC](https://discuss.elastic.co/t/count-in-c-nest-for-es-5-5/98525/2 "2017-08-28T11:31:21Z")

</div>

Ok, figured it out:

```
var settings = new ConnectionSettings(new Uri("http://server:9200"));
var client = new ElasticClient(settings);
var clusterStats = client.ClusterStats();
var docsCount = clusterStats.Indices.Documents.Count;

```

This returns the same number as using `GET server:9200/_count`

Greetings  
Martin

---

<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: [September 25, 2017, 11:31am UTC](https://discuss.elastic.co/t/count-in-c-nest-for-es-5-5/98525/3 "2017-09-25T11:31:54Z")

</div>

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