Index Nested object 6.2

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).

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).

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?

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

1 Like

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 and to the _id2 and 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) ?

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.

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.

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

1 Like

Thanks for your answer. :wink:

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