# Count total records in elasticsearch

**URL:** <https://discuss.elastic.co/t/count-total-records-in-elasticsearch/50366>\
**Category:** Elasticsearch\
**Created:** [May 18, 2016, 6:25pm UTC](https://discuss.elastic.co/t/count-total-records-in-elasticsearch/50366 "2016-05-18T18:25:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart\_Cracraft1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stuart_cracraft1/32/8036_2.png) [@Stuart\_Cracraft1](https://discuss.elastic.co/u/Stuart_Cracraft1)\
**Post date:** [May 18, 2016, 6:25pm UTC](https://discuss.elastic.co/t/count-total-records-in-elasticsearch/50366/1 "2016-05-18T18:25:12Z")

</div>

Hi,

Is there a simple command-line to count total records in elasticsearch?

Thanks.

---

<div class="post-metadata">

**Author:** ![thn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thn/32/8061_2.png) [@thn](https://discuss.elastic.co/u/thn)\
**Post date:** [May 18, 2016, 6:30pm UTC](https://discuss.elastic.co/t/count-total-records-in-elasticsearch/50366/2 "2016-05-18T18:30:57Z")

</div>

If you search, you'll find the link below... try to read the online document, it has a lot of info you need there...

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html)

---

<div class="post-metadata">

**Author:** ![Stuart\_Cracraft1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stuart_cracraft1/32/8036_2.png) [@Stuart\_Cracraft1](https://discuss.elastic.co/u/Stuart_Cracraft1)\
**Post date:** [May 18, 2016, 6:55pm UTC](https://discuss.elastic.co/t/count-total-records-in-elasticsearch/50366/3 "2016-05-18T18:55:05Z")

</div>

Great!

---

<div class="post-metadata">

**Author:** ![sandros](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandros/32/6348_2.png) [@sandros](https://discuss.elastic.co/u/sandros)\
**Post date:** [May 19, 2016, 1:40pm UTC](https://discuss.elastic.co/t/count-total-records-in-elasticsearch/50366/4 "2016-05-19T13:40:58Z")

</div>

Just beware, it can happen that count reaches the timeout, just so you know and are not so surprised by an unexpected place for the code to crash 🙂

---

<div class="post-metadata">

**Author:** ![Stuart\_Cracraft1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stuart_cracraft1/32/8036_2.png) [@Stuart\_Cracraft1](https://discuss.elastic.co/u/Stuart_Cracraft1)\
**Post date:** [May 19, 2016, 2:16pm UTC](https://discuss.elastic.co/t/count-total-records-in-elasticsearch/50366/5 "2016-05-19T14:16:36Z")

</div>

I have this going into collectd, graphite and sensu.

Any of the NaN's due to slow  
count within the custom exec  
collectd wakeup period for  
curl's against the ES API  
do not count against the cluster  
unless I only get NaN's for a period.

The rest of the calculation is done with the derive option on the count in collectd to determine when there are drastic drops in cluster insertion rates.

A separate question: are there any tools which let one

a) retrieve logstash files in their  
entirety in a given day's logstash  
(not the index and all its  
documents though that would be  
the simple case)

b) permit deletion of arbitrary  
data including individual logstash  
stored files on a given day  
(not the entire day though  
that would be the simple case)

I do have curator enabled but it is just to keep a year's data, so when I want to go special-purpose cleaning I would like to have a tool beyond  
API calls.

And not have to reinvent the wheel.

---

<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:** [July 5, 2017, 10:50pm UTC](https://discuss.elastic.co/t/count-total-records-in-elasticsearch/50366/6 "2017-07-05T22:50:24Z")

</div>


