# Number of document of all indices with a single request

**URL:** <https://discuss.elastic.co/t/number-of-document-of-all-indices-with-a-single-request/280405>\
**Category:** Elasticsearch\
**Created:** [August 4, 2021, 9:18am UTC](https://discuss.elastic.co/t/number-of-document-of-all-indices-with-a-single-request/280405 "2021-08-04T09:18:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ELJIE](https://avatars.discourse-cdn.com/v4/letter/e/d9b06d/32.png) [@ELJIE](https://discuss.elastic.co/u/ELJIE)\
**Post date:** [August 4, 2021, 9:18am UTC](https://discuss.elastic.co/t/number-of-document-of-all-indices-with-a-single-request/280405/1 "2021-08-04T09:18:09Z")

</div>

Hello,  
I'm trying to find a tip to retrieve the document count of each index  
in elastic with a single request  
Ex: in elastic there is:  
Index1 with 10 document,  
Index2 with 20 document,  
Index3 with 30 document,  
Index4 with 40 document,  
Index5 with 50 document,

do  
GET Index1/\_count ==\> 10  
GET Index2/\_count ==\> 20

but  
GET Index\*/\_count ==\> 150 this is the total of documents from all indices

Do you have any idea how to do it  
to have a return as follows: ?  
{  
"Index1": 10,  
"Index2": 20,  
"Index3" : 30,  
"Index4": 40 ,  
"Index5" : 50  
}

Thx

---

<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:** [August 4, 2021, 9:34am UTC](https://discuss.elastic.co/t/number-of-document-of-all-indices-with-a-single-request/280405/2 "2021-08-04T09:34:47Z")

</div>

You can do something like:

```auto
GET /_search?filter_path=aggregations.index.buckets
{
  "size": 0,
  "aggs": {
    "index": {
      "terms": {
        "field": "_index",
        "size": 1000
      }
    }
  }
}

```

But this is may be better:

```auto
GET /_cat/indices?v&h=index,dc

```

Or

```auto
GET /_cat/indices?v&h=index,dc&format=json

```

---

<div class="post-metadata">

**Author:** ![ELJIE](https://avatars.discourse-cdn.com/v4/letter/e/d9b06d/32.png) [@ELJIE](https://discuss.elastic.co/u/ELJIE)\
**Post date:** [August 4, 2021, 10:00am UTC](https://discuss.elastic.co/t/number-of-document-of-all-indices-with-a-single-request/280405/3 "2021-08-04T10:00:06Z")

</div>

Thank you for the answer,  
The first request works very well

however we cannot use a request : \_cat/indices  
because it does not return the number of document on elastic but it is based on the Lucene engine to return information that does not correspond to a count

thanks again

---

<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 1, 2021, 10:00am UTC](https://discuss.elastic.co/t/number-of-document-of-all-indices-with-a-single-request/280405/4 "2021-09-01T10:00:50Z")

</div>

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