# Index Nested object 6.2

**URL:** <https://discuss.elastic.co/t/index-nested-object-6-2/123054>\
**Category:** Elasticsearch\
**Created:** [March 8, 2018, 11:20am UTC](https://discuss.elastic.co/t/index-nested-object-6-2/123054 "2018-03-08T11:20:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [March 8, 2018, 11:20am UTC](https://discuss.elastic.co/t/index-nested-object-6-2/123054/1 "2018-03-08T11:20:40Z")

</div>

Hi,

I've read that Elasticsearch's Nested object are usefull but aren't independant from their root index and  
reindex the whole document if reindexed ([https://www.elastic.co/blog/managing-relations-inside-elasticsearch](https://www.elastic.co/blog/managing-relations-inside-elasticsearch)).

But on the up to date documentation (6.2) it is said that "nested documents are indexed as separate documents" ([https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html)).

So I want to be sure, If I use this structure and reindex a Nested object, does it reindex the root index? Does it reindex the other nested object in the root index?

---

<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:** [March 8, 2018, 11:39am UTC](https://discuss.elastic.co/t/index-nested-object-6-2/123054/2 "2018-03-08T11:39:45Z")

</div>

Yes, it does reindex the entire nested document, including root and all nested documents.

---

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [March 8, 2018, 12:04pm UTC](https://discuss.elastic.co/t/index-nested-object-6-2/123054/3 "2018-03-08T12:04:10Z")

</div>

But let's say that in my Index "Personne" which got numerous field in which there is "name",  
I have PUT two entity, Peter (\_id : 1) and Alice (\_id : 2).  
There is also a nested object in Personne to keep their different mail adresses.  
I have posted [alice1@mail.com](mailto:alice1@mail.com) and to the \_id2 and [peter1@mail.com](mailto:peter1@mail.com) to the \_id1.

Now let's say that I change the adress of alice so that she got a second adress as well.

```
POST Personne/_doc/2/_update
{
    "script" : {
        "lang": "painless",
        "source": "ctx._source.mail = params.mail",
        "params" : {
            "mail" : [
             {
             "mail1" : " alice1@mail.com",
            "mail2" : "alice2@mail.com"
              }
            ]
         }
      }
  }

```

What would be reindexed? Every field concerning Alice (her name, both of her mails)?  
Everything inside Personne (including everything concerning Peter) ?

---

<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:** [March 8, 2018, 2:54pm UTC](https://discuss.elastic.co/t/index-nested-object-6-2/123054/4 "2018-03-08T14:54:59Z")

</div>

The entire document will be reindexed, the root as well as all nested documents. If I have a root document with a list of 5 nested documents and add another one, all 7 documents will be (re)indexed.

---

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [March 8, 2018, 3:46pm UTC](https://discuss.elastic.co/t/index-nested-object-6-2/123054/5 "2018-03-08T15:46:55Z")

</div>

Thanks for your answers and sorry to bother you @Christian_Dahlqvist but I may haven't make myself comprehensible.  
I don't mean that the root will be re-indexed as the mapping/schema will be changed.  
I mean that if I add a nested object as in I add data (this person will have another mail adress). Will the index of the data of the person be reindexed/updated?

I want to add nested object causing as less operation as possible.

---

<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:** [March 8, 2018, 3:49pm UTC](https://discuss.elastic.co/t/index-nested-object-6-2/123054/6 "2018-03-08T15:49:57Z")

</div>

Yes, that is what I have tried to explain. Updating a nested document can be expensive.

---

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [March 8, 2018, 3:51pm UTC](https://discuss.elastic.co/t/index-nested-object-6-2/123054/7 "2018-03-08T15:51:53Z")

</div>

Thanks for your answer. 😉

---

<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:** [April 5, 2018, 3:52pm UTC](https://discuss.elastic.co/t/index-nested-object-6-2/123054/8 "2018-04-05T15:52:19Z")

</div>

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