# Elastic hadoop count

**URL:** <https://discuss.elastic.co/t/elastic-hadoop-count/44294>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [March 14, 2016, 8:30am UTC](https://discuss.elastic.co/t/elastic-hadoop-count/44294 "2016-03-14T08:30:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjuexuan](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@cjuexuan](https://discuss.elastic.co/u/cjuexuan)\
**Post date:** [March 14, 2016, 8:30am UTC](https://discuss.elastic.co/t/elastic-hadoop-count/44294/1 "2016-03-14T08:30:34Z")

</div>

in my code , I want to count the index size ,like rest api:

```auto
curl -XGET 'host:port/index/type/_count&q=xxx:xxx'

```

but in docs ,I can't find some way to solve this problem , if we cache the data use `rdd.count` or `dataframe.count` ,too slow and if our data size is larger ,no result about the count,how can we make it run quickly

in elastic4s ,we can use `search in index/type query xxx size 0` and get hit to solve this problem

---

<div class="post-metadata">

**Author:** ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)\
**Post date:** [March 21, 2016, 10:11am UTC](https://discuss.elastic.co/t/elastic-hadoop-count/44294/2 "2016-03-21T10:11:58Z")

</div>

Doing the query manually through elastic4s might remain the only option for the time being. Count was implemented some time ago to do just that however it changed semantics since in Spark, count actually instantiates all entries.  
Going forward we might just add an esCount method however that implies the RDD in question is an ES one. Or potentially bind it to SparkContext/SQLContex.t

---

<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 6, 2017, 1:25pm UTC](https://discuss.elastic.co/t/elastic-hadoop-count/44294/3 "2017-07-06T13:25:42Z")

</div>


