# Head shows incorrect docs count if nested type field is defined in mapping

**URL:** https://discuss.elastic.co/t/head-shows-incorrect-docs-count-if-nested-type-field-is-defined-in-mapping/23270
**Category:** Elasticsearch
**Created:** [April 16, 2015, 9:36am UTC](https://discuss.elastic.co/t/head-shows-incorrect-docs-count-if-nested-type-field-is-defined-in-mapping/23270 "2015-04-16T09:36:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)
#### Post date: [April 16, 2015, 9:36am UTC](https://discuss.elastic.co/t/head-shows-incorrect-docs-count-if-nested-type-field-is-defined-in-mapping/23270/1 "2015-04-16T09:36:04Z")

</div>

I was confused by the docs count value displaying in head plugin if there  
is nest type field define in mapping

For example, I created a new index with following mapping:  
{  
"mappings" : {  
"doc" : {  
"properties" : {  
"QueryClicks" : {  
"type" : "nested",  
"properties" : {  
"Count" : {  
"type" : "long"  
},  
"Term" : {  
"type" : "string"  
}  
}  
},  
"Title" : {  
"type" : "string"  
}  
}  
}  
}  
}

And then insert ONE doc:  
{  
"QueryClicks":[{"Term":"term1","Count":10},{"Term":"term2","Count":10}],  
"Title":"test title"  
}

Then refresh Head, the docs shown on Head is 3:  
size: 3.57ki (6.97ki)  
docs: 3 (3)

Why?

--  
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/f3148390-9174-4521-b97a-94f6cbfe4307%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f3148390-9174-4521-b97a-94f6cbfe4307%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)
#### Post date: [April 17, 2015, 2:35am UTC](https://discuss.elastic.co/t/head-shows-incorrect-docs-count-if-nested-type-field-is-defined-in-mapping/23270/2 "2015-04-17T02:35:56Z")

</div>

BTW: If I just remove the "type":"nested" from the mapping, the doc count  
then is correct after insert one document.  
Anyone has suggestions resolve this issue?

On Thursday, April 16, 2015 at 5:36:04 PM UTC+8, Xudong You wrote:

> I was confused by the docs count value displaying in head plugin if there  
> is nest type field define in mapping
> 
> For example, I created a new index with following mapping:  
> {  
> "mappings" : {  
> "doc" : {  
> "properties" : {  
> "QueryClicks" : {  
> "type" : "nested",  
> "properties" : {  
> "Count" : {  
> "type" : "long"  
> },  
> "Term" : {  
> "type" : "string"  
> }  
> }  
> },  
> "Title" : {  
> "type" : "string"  
> }  
> }  
> }  
> }  
> }
> 
> And then insert ONE doc:  
> {  
> "QueryClicks":[{"Term":"term1","Count":10},{"Term":"term2","Count":10}],  
> "Title":"test title"  
> }
> 
> Then refresh Head, the docs shown on Head is 3:  
> size: 3.57ki (6.97ki)  
> docs: 3 (3)
> 
> Why?

--  
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/6173334c-dbc6-46f7-b191-5c2f92421392%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6173334c-dbc6-46f7-b191-5c2f92421392%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)
#### Post date: [April 17, 2015, 2:44am UTC](https://discuss.elastic.co/t/head-shows-incorrect-docs-count-if-nested-type-field-is-defined-in-mapping/23270/3 "2015-04-17T02:44:29Z")

</div>

Just figured out that the doc count is actually the number of document +  
the number of items of nested field, in my case, the QueryClicks field has  
two items, then the total number of doc shown on head is 1+2=3.  
But this might confuse the people who view doc counts on head or other UI  
plug-in.

Is there anyway let head just show the doc count, regarding if the doc has  
nested field or not.

On Thursday, April 16, 2015 at 5:36:04 PM UTC+8, Xudong You wrote:

> I was confused by the docs count value displaying in head plugin if there  
> is nest type field define in mapping
> 
> For example, I created a new index with following mapping:  
> {  
> "mappings" : {  
> "doc" : {  
> "properties" : {  
> "QueryClicks" : {  
> "type" : "nested",  
> "properties" : {  
> "Count" : {  
> "type" : "long"  
> },  
> "Term" : {  
> "type" : "string"  
> }  
> }  
> },  
> "Title" : {  
> "type" : "string"  
> }  
> }  
> }  
> }  
> }
> 
> And then insert ONE doc:  
> {  
> "QueryClicks":[{"Term":"term1","Count":10},{"Term":"term2","Count":10}],  
> "Title":"test title"  
> }
> 
> Then refresh Head, the docs shown on Head is 3:  
> size: 3.57ki (6.97ki)  
> docs: 3 (3)
> 
> Why?

--  
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/b6dc87e7-f242-40f9-9ab0-d98c0c08e2c0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b6dc87e7-f242-40f9-9ab0-d98c0c08e2c0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Glen\_Smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/glen_smith/32/111656_2.png) [@Glen\_Smith](https://discuss.elastic.co/u/Glen_Smith)
#### Post date: [April 17, 2015, 3:14am UTC](https://discuss.elastic.co/t/head-shows-incorrect-docs-count-if-nested-type-field-is-defined-in-mapping/23270/4 "2015-04-17T03:14:36Z")

</div>

Go to the "browser" tab and select the type. That will show the count you  
are looking for.

On Thursday, April 16, 2015 at 10:44:29 PM UTC-4, Xudong You wrote:

> Just figured out that the doc count is actually the number of document +  
> the number of items of nested field, in my case, the QueryClicks field has  
> two items, then the total number of doc shown on head is 1+2=3.  
> But this might confuse the people who view doc counts on head or other UI  
> plug-in.
> 
> Is there anyway let head just show the doc count, regarding if the doc has  
> nested field or not.
> 
> On Thursday, April 16, 2015 at 5:36:04 PM UTC+8, Xudong You wrote:
> 
> > I was confused by the docs count value displaying in head plugin if there  
> > is nest type field define in mapping
> > 
> > For example, I created a new index with following mapping:  
> > {  
> > "mappings" : {  
> > "doc" : {  
> > "properties" : {  
> > "QueryClicks" : {  
> > "type" : "nested",  
> > "properties" : {  
> > "Count" : {  
> > "type" : "long"  
> > },  
> > "Term" : {  
> > "type" : "string"  
> > }  
> > }  
> > },  
> > "Title" : {  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > And then insert ONE doc:  
> > {  
> > "QueryClicks":[{"Term":"term1","Count":10},{"Term":"term2","Count":10}],  
> > "Title":"test title"  
> > }
> > 
> > Then refresh Head, the docs shown on Head is 3:  
> > size: 3.57ki (6.97ki)  
> > docs: 3 (3)
> > 
> > Why?

--  
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/bf13dc04-a9c7-4cd4-9136-a9f8fcf1567f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bf13dc04-a9c7-4cd4-9136-a9f8fcf1567f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)
#### Post date: [April 17, 2015, 3:42am UTC](https://discuss.elastic.co/t/head-shows-incorrect-docs-count-if-nested-type-field-is-defined-in-mapping/23270/5 "2015-04-17T03:42:08Z")

</div>

Thanks Glen!

On Friday, April 17, 2015 at 11:14:36 AM UTC+8, Glen Smith wrote:

> Go to the "browser" tab and select the type. That will show the count you  
> are looking for.
> 
> On Thursday, April 16, 2015 at 10:44:29 PM UTC-4, Xudong You wrote:
> 
> > Just figured out that the doc count is actually the number of document +  
> > the number of items of nested field, in my case, the QueryClicks field has  
> > two items, then the total number of doc shown on head is 1+2=3.  
> > But this might confuse the people who view doc counts on head or other UI  
> > plug-in.
> > 
> > Is there anyway let head just show the doc count, regarding if the doc  
> > has nested field or not.
> > 
> > On Thursday, April 16, 2015 at 5:36:04 PM UTC+8, Xudong You wrote:
> > 
> > > I was confused by the docs count value displaying in head plugin if  
> > > there is nest type field define in mapping
> > > 
> > > For example, I created a new index with following mapping:  
> > > {  
> > > "mappings" : {  
> > > "doc" : {  
> > > "properties" : {  
> > > "QueryClicks" : {  
> > > "type" : "nested",  
> > > "properties" : {  
> > > "Count" : {  
> > > "type" : "long"  
> > > },  
> > > "Term" : {  
> > > "type" : "string"  
> > > }  
> > > }  
> > > },  
> > > "Title" : {  
> > > "type" : "string"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > And then insert ONE doc:  
> > > {
> > > 
> > > "QueryClicks":[{"Term":"term1","Count":10},{"Term":"term2","Count":10}],  
> > > "Title":"test title"  
> > > }
> > > 
> > > Then refresh Head, the docs shown on Head is 3:  
> > > size: 3.57ki (6.97ki)  
> > > docs: 3 (3)
> > > 
> > > Why?

--  
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/c6512d9d-b4ff-49ca-b255-c934cfba146b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c6512d9d-b4ff-49ca-b255-c934cfba146b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:19am UTC](https://discuss.elastic.co/t/head-shows-incorrect-docs-count-if-nested-type-field-is-defined-in-mapping/23270/6 "2017-07-06T00:19:13Z")

</div>


