Using parent-child relationships
In the previous section, we discussed the ability to index nested documents along with a parent one. However, even though the nested documents are indexed as separate documents in the index, we can't change a single nested document (unless we use the update API). However, ElasticSearch allows us to have a real parent-child relationship and we will look at it in the following sections.
Mappings and indexing
Let's use our previous example with the clothing store. However, what we would like to have is the ability to update sizes and colors without the need of indexing the whole document after each change. In order to do that, we will use the parent-child functionality of ElasticSearch.
Creating parent mappings
So now, the only field we need to have in our parent document is the name. We don't need anything more than that. So in order to create our mapping in the shop
index, we would run the following command:
curl -XPUT 'localhost:9200/shop/cloth/_mapping' -d '...