# Understanding Index Stats API Better

**URL:** https://discuss.elastic.co/t/understanding-index-stats-api-better/15296
**Category:** Elasticsearch
**Created:** [January 17, 2014, 1:53pm UTC](https://discuss.elastic.co/t/understanding-index-stats-api-better/15296 "2014-01-17T13:53:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![vaidik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaidik/32/1134_2.png) [@vaidik](https://discuss.elastic.co/u/vaidik)
#### Post date: [January 17, 2014, 1:53pm UTC](https://discuss.elastic.co/t/understanding-index-stats-api-better/15296/1 "2014-01-17T13:53:56Z")

</div>

Hi Guys,

I am trying to understand Index Stats API better here. I have two indices,  
both with the same data. However, the mappings differ. One of them has some  
fields that have type as _nested_. Now the number of documents shown in the  
Index Stats API response for the one that has nested type fields is more  
than the one that does not have nested type fields. Although when I do a  
GET /INDEX\_NAME/\_search?search\_type=count for both the indices, I get the  
same count in the response.

Does this mean that Index Stats API is counting nested documents separately?

Would appreciate some clarification on this.

Thanks,  
Vaidik Kapoor  
vaidikkapoor.info

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CACWtv5kKM7Y255tEVyvfZAfYryx91%2BYk0rBPY7SrMV2YcnN7Dw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CACWtv5kKM7Y255tEVyvfZAfYryx91%2BYk0rBPY7SrMV2YcnN7Dw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)
#### Post date: [January 17, 2014, 6:47pm UTC](https://discuss.elastic.co/t/understanding-index-stats-api-better/15296/2 "2014-01-17T18:47:03Z")

</div>

Yes, nested documents are separate lucene documents, that are never  
returned (for now) by the ordinary elasticsearch search apis as they are  
filtered out by default. Only a single document gets returned (and  
counted), which contains both parent and nested docs. On the lucene index  
you have though separate docs stored on the same block.

The \_stats api reads the number of documents from lucene (including  
nested), while the count and search apis execute a query and filter the  
nested docs out.

Hope this clarifies things

On Friday, January 17, 2014 2:53:56 PM UTC+1, Vaidik Kapoor wrote:

> Hi Guys,
> 
> I am trying to understand Index Stats API better here. I have two indices,  
> both with the same data. However, the mappings differ. One of them has some  
> fields that have type as _nested_. Now the number of documents shown in  
> the Index Stats API response for the one that has nested type fields is  
> more than the one that does not have nested type fields. Although when I do  
> a GET /INDEX\_NAME/\_search?search\_type=count for both the indices, I get the  
> same count in the response.
> 
> Does this mean that Index Stats API is counting nested documents  
> separately?
> 
> Would appreciate some clarification on this.
> 
> Thanks,  
> Vaidik Kapoor  
> vaidikkapoor.info

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f9fc4f87-8c65-4ece-9399-0264ded57985%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f9fc4f87-8c65-4ece-9399-0264ded57985%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![vaidik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaidik/32/1134_2.png) [@vaidik](https://discuss.elastic.co/u/vaidik)
#### Post date: [January 18, 2014, 11:04am UTC](https://discuss.elastic.co/t/understanding-index-stats-api-better/15296/3 "2014-01-18T11:04:07Z")

</div>

Thanks for the clarification Luca! 🙂

Vaidik Kapoor  
vaidikkapoor.info

On 18 January 2014 00:17, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com) wrote:

> Yes, nested documents are separate lucene documents, that are never  
> returned (for now) by the ordinary elasticsearch search apis as they are  
> filtered out by default. Only a single document gets returned (and  
> counted), which contains both parent and nested docs. On the lucene index  
> you have though separate docs stored on the same block.
> 
> The \_stats api reads the number of documents from lucene (including  
> nested), while the count and search apis execute a query and filter the  
> nested docs out.
> 
> Hope this clarifies things
> 
> On Friday, January 17, 2014 2:53:56 PM UTC+1, Vaidik Kapoor wrote:
> 
> > Hi Guys,
> > 
> > I am trying to understand Index Stats API better here. I have two  
> > indices, both with the same data. However, the mappings differ. One of them  
> > has some fields that have type as _nested_. Now the number of documents  
> > shown in the Index Stats API response for the one that has nested type  
> > fields is more than the one that does not have nested type fields. Although  
> > when I do a GET /INDEX\_NAME/\_search?search\_type=count for both the  
> > indices, I get the same count in the response.
> > 
> > Does this mean that Index Stats API is counting nested documents  
> > separately?
> > 
> > Would appreciate some clarification on this.
> > 
> > Thanks,  
> > Vaidik Kapoor  
> > vaidikkapoor.info
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/f9fc4f87-8c65-4ece-9399-0264ded57985%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f9fc4f87-8c65-4ece-9399-0264ded57985%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CACWtv5mNg2Rm%2BjFOUGn7708gkHNYvty6xdCNp6BE%2Bt1BFwjF8w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CACWtv5mNg2Rm%2BjFOUGn7708gkHNYvty6xdCNp6BE%2Bt1BFwjF8w%40mail.gmail.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, 1:56am UTC](https://discuss.elastic.co/t/understanding-index-stats-api-better/15296/4 "2017-07-06T01:56:03Z")

</div>


