# Confirming: Each nested doc in a doc counts towards total count?

**URL:** https://discuss.elastic.co/t/confirming-each-nested-doc-in-a-doc-counts-towards-total-count/12919
**Category:** Elasticsearch
**Created:** [July 24, 2013, 1:56pm UTC](https://discuss.elastic.co/t/confirming-each-nested-doc-in-a-doc-counts-towards-total-count/12919 "2013-07-24T13:56:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Justin\_Treher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_treher/32/45243_2.png) [@Justin\_Treher](https://discuss.elastic.co/u/Justin_Treher)
#### Post date: [July 24, 2013, 1:56pm UTC](https://discuss.elastic.co/t/confirming-each-nested-doc-in-a-doc-counts-towards-total-count/12919/1 "2013-07-24T13:56:36Z")

</div>

I just wanted to confirm that

1. the doc count ES provides for the index includes the sum of nested docs  
and top level docs in all types, and
2. the doc count for the type includes just the sum of top level docs in  
the type?

Thanks!

--  
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: ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)
#### Post date: [July 29, 2013, 9:58am UTC](https://discuss.elastic.co/t/confirming-each-nested-doc-in-a-doc-counts-towards-total-count/12919/2 "2013-07-29T09:58:02Z")

</div>

The total hits is always based on the number of root documents, so  
excluding the hit count on the nested level.

On 24 July 2013 15:56, Justin Treher [jtreher@gmail.com](mailto:jtreher@gmail.com) wrote:

> I just wanted to confirm that
> 
> 1. the doc count ES provides for the index includes the sum of nested docs  
> and top level docs in all types, and
> 2. the doc count for the type includes just the sum of top level docs in  
> the type?
> 
> Thanks!
> 
> --  
> 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).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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: ![Justin\_Treher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_treher/32/45243_2.png) [@Justin\_Treher](https://discuss.elastic.co/u/Justin_Treher)
#### Post date: [July 31, 2013, 3:28pm UTC](https://discuss.elastic.co/t/confirming-each-nested-doc-in-a-doc-counts-towards-total-count/12919/3 "2013-07-31T15:28:22Z")

</div>

When I'm looking at ES head it is showing a count that is much higher than  
my bulk index source. The only explanation is that it is including the  
nested docs as part of its count. I know that head just pulls a stat call  
on the server.

On Monday, July 29, 2013 5:58:02 AM UTC-4, Martijn v Groningen wrote:

> The total hits is always based on the number of root documents, so  
> excluding the hit count on the nested level.
> 
> On 24 July 2013 15:56, Justin Treher \<[jtr...@gmail.com](mailto:jtr...@gmail.com) \<javascript:\>\>wrote:
> 
> > I just wanted to confirm that
> > 
> > 1. the doc count ES provides for the index includes the sum of nested  
> > docs and top level docs in all types, and
> > 2. the doc count for the type includes just the sum of top level docs in  
> > the type?
> > 
> > Thanks!
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Met vriendelijke groet,
> 
> Martijn van Groningen

--  
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: ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)
#### Post date: [July 31, 2013, 8:52pm UTC](https://discuss.elastic.co/t/confirming-each-nested-doc-in-a-doc-counts-towards-total-count/12919/4 "2013-07-31T20:52:25Z")

</div>

I thought you were talking about the doc count in the search api, so yes,  
the stats shows the number of Lucene documents that are in your index and  
this includes the nested docs.

On 31 July 2013 17:28, Justin Treher [jtreher@gmail.com](mailto:jtreher@gmail.com) wrote:

> When I'm looking at ES head it is showing a count that is much higher than  
> my bulk index source. The only explanation is that it is including the  
> nested docs as part of its count. I know that head just pulls a stat call  
> on the server.
> 
> On Monday, July 29, 2013 5:58:02 AM UTC-4, Martijn v Groningen wrote:
> 
> > The total hits is always based on the number of root documents, so  
> > excluding the hit count on the nested level.
> > 
> > On 24 July 2013 15:56, Justin Treher [jtr...@gmail.com](mailto:jtr...@gmail.com) wrote:
> > 
> > > I just wanted to confirm that
> > > 
> > > 1. the doc count ES provides for the index includes the sum of nested  
> > > docs and top level docs in all types, and
> > > 2. the doc count for the type includes just the sum of top level docs in  
> > > the type?
> > > 
> > > Thanks!
> > > 
> > > --  
> > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > Met vriendelijke groet,
> > 
> > Martijn van Groningen

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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:23am UTC](https://discuss.elastic.co/t/confirming-each-nested-doc-in-a-doc-counts-towards-total-count/12919/5 "2017-07-06T02:23:29Z")

</div>


