# Mapping Explosion in Nested Datatype

**URL:** <https://discuss.elastic.co/t/mapping-explosion-in-nested-datatype/90835>\
**Category:** Elasticsearch\
**Created:** [June 26, 2017, 2:51pm UTC](https://discuss.elastic.co/t/mapping-explosion-in-nested-datatype/90835 "2017-06-26T14:51:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)\
**Post date:** [June 26, 2017, 2:51pm UTC](https://discuss.elastic.co/t/mapping-explosion-in-nested-datatype/90835/1 "2017-06-26T14:51:58Z")

</div>

The documentation for nested datatype ([https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html)) says that in order to prevent mapping explosion the number of nested fields per index is limited to 50. But one can override that by changing the default setting.

I am in the process of creating an index that can have a lot of nested documents. My document structure will look something like:

```
{
  "personid": 1,
  "comments":[
    {},
    {},
    {},
    ...
  ]
}

```

Each person can have multiple comments, is each comment considered it's own nested document? What problems will I run into if I set up a person index where each document can have as many as 10,000 comments per person?

Thanks.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 26, 2017, 2:59pm UTC](https://discuss.elastic.co/t/mapping-explosion-in-nested-datatype/90835/2 "2017-06-26T14:59:25Z")

</div>

Having documents containing a lot of nested components can make updates quite expensive. Each nested component of a document is indexed as a separate document behind the scenes, and when anything is updated these are all updated/reindexed. If you have a relatively static dataset this maybe fine, but you may want to consider breaking up and flattening parts of your data model.

---

<div class="post-metadata">

**Author:** ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)\
**Post date:** [June 26, 2017, 3:09pm UTC](https://discuss.elastic.co/t/mapping-explosion-in-nested-datatype/90835/3 "2017-06-26T15:09:21Z")

</div>

@Christian_Dahlqvist Thanks for the response. Would having a lot of nested documents in the index affect query performance?

My dataset is not completely static but it does not change a lot either. The personid field is also the document id. I was thinking of replacing the entire document whenever a comment gets added to a person document. Is this a very unreasonable/un-maintainable approach?

---

<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 24, 2017, 3:09pm UTC](https://discuss.elastic.co/t/mapping-explosion-in-nested-datatype/90835/4 "2017-07-24T15:09:31Z")

</div>

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