# Max\_docs and count api does not return the same number

**URL:** https://discuss.elastic.co/t/max-docs-and-count-api-does-not-return-the-same-number/10561
**Category:** Elasticsearch
**Created:** [January 30, 2013, 7:41pm UTC](https://discuss.elastic.co/t/max-docs-and-count-api-does-not-return-the-same-number/10561 "2013-01-30T19:41:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Chunlei\_Wu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chunlei_wu/32/824_2.png) [@Chunlei\_Wu](https://discuss.elastic.co/u/Chunlei_Wu)
#### Post date: [January 30, 2013, 7:41pm UTC](https://discuss.elastic.co/t/max-docs-and-count-api-does-not-return-the-same-number/10561/1 "2013-01-30T19:41:36Z")

</div>

I have a ES cluster with 2 nodes (v0.20.2). I built a new index with 609218  
docs without any error (every doc was inserted just once). Then I have this  
returned from status:

docs: {  
num\_docs: 876969  
max\_doc: 876969  
deleted\_docs: 0  
}

while the count API returns the 609218 docs:

curl http://es\_node:9200/my\_index/my\_type/\_count  
{"count":609218,"\_shards":{"total":5,"successful":5,"failed":0}}

And my index settings look like this:  
settings: {  
index.number\_of\_replicas: 1  
index.version.created: 191199  
index.number\_of\_shards: 5  
}

Why does num\_docs show different than 609218? I am also not sure why  
"index.version.created: 191199" as my docs have no version changes.

Thanks,

Chunlei

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [January 31, 2013, 8:52am UTC](https://discuss.elastic.co/t/max-docs-and-count-api-does-not-return-the-same-number/10561/2 "2013-01-31T08:52:45Z")

</div>

On Wed, 2013-01-30 at 11:41 -0800, Chunlei Wu wrote:

> I have a ES cluster with 2 nodes (v0.20.2). I built a new index with  
> 609218 docs without any error (every doc was inserted just once). Then  
> I have this returned from status:
> 
> docs: {  
> num\_docs: 876969  
> max\_doc: 876969  
> deleted\_docs: 0  
> }
> 
> while the count API returns the 609218 docs:

Do you use the nested mapping at all? Each nested doc counts as a  
separate doc, even though it is not visible to the user.

clint

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Chunlei\_Wu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chunlei_wu/32/824_2.png) [@Chunlei\_Wu](https://discuss.elastic.co/u/Chunlei_Wu)
#### Post date: [January 31, 2013, 10:22pm UTC](https://discuss.elastic.co/t/max-docs-and-count-api-does-not-return-the-same-number/10561/3 "2013-01-31T22:22:37Z")

</div>

Aha, that's exactly right! I do have "nested" type in the mapping file. 87  
6969-609218=267751 is the exact number of nested docs.

It's good to know that. Maybe worth mentioning this in "nested type" page.  
I was worried if I did the indexing correctly.

Thanks a lot!

Chunlei

On Thursday, January 31, 2013 12:52:45 AM UTC-8, Clinton Gormley wrote:

> On Wed, 2013-01-30 at 11:41 -0800, Chunlei Wu wrote:
> 
> > I have a ES cluster with 2 nodes (v0.20.2). I built a new index with  
> > 609218 docs without any error (every doc was inserted just once). Then  
> > I have this returned from status:
> > 
> > docs: {  
> > num\_docs: 876969  
> > max\_doc: 876969  
> > deleted\_docs: 0  
> > }
> > 
> > while the count API returns the 609218 docs:
> 
> Do you use the nested mapping at all? Each nested doc counts as a  
> separate doc, even though it is not visible to the user.
> 
> clint

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:53am UTC](https://discuss.elastic.co/t/max-docs-and-count-api-does-not-return-the-same-number/10561/4 "2017-07-06T02:53:41Z")

</div>


