How to get a count of the number of documents in an Elasticsearch Index? - Big Data In Real World

How to get a count of the number of documents in an Elasticsearch Index?

How does Cartesian Product Join work in Spark?
January 29, 2021
Why does Hadoop need classes like Text instead of String?
February 3, 2021
How does Cartesian Product Join work in Spark?
January 29, 2021
Why does Hadoop need classes like Text instead of String?
February 3, 2021

It is quite common that you have a need to find the count of the number of documents in an Elasticsearch index. There are several ways to find this. Here are couple of ways.

Solution

_count

Use this method if you are trying to get the count programmatically.

[osboxes@wk1 ~]$ curl "localhost:9200/account/_count"

{"count":1000,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0}}

 

_cat

This list all the indices in your cluster and it lists the information about all the indices in a nice tabular format.

[osboxes@wk1 ~]$ curl http://localhost:9200/_cat/indices?v

health status index   uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   account avtO6o3jTmWtgAyQwTTM6Q   1   1       1000            0    391.4kb        391.4kb

 

Big Data In Real World
Big Data In Real World
We are a group of Big Data engineers who are passionate about Big Data and related Big Data technologies. We have designed, developed, deployed and maintained Big Data applications ranging from batch to real time streaming big data platforms. We have seen a wide range of real world big data problems, implemented some innovative and complex (or simple, depending on how you look at it) solutions.

Comments are closed.

How to get a count of the number of documents in an Elasticsearch Index?
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.

Hadoop In Real World is now Big Data In Real World!

X