# Mapping Relationship Dynamically in ES 6.0

**URL:** <https://discuss.elastic.co/t/mapping-relationship-dynamically-in-es-6-0/143205>\
**Category:** Elasticsearch\
**Created:** [August 6, 2018, 6:47pm UTC](https://discuss.elastic.co/t/mapping-relationship-dynamically-in-es-6-0/143205 "2018-08-06T18:47:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pDonS](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@pDonS](https://discuss.elastic.co/u/pDonS)\
**Post date:** [August 6, 2018, 6:47pm UTC](https://discuss.elastic.co/t/mapping-relationship-dynamically-in-es-6-0/143205/1 "2018-08-06T18:47:43Z")

</div>

Hi All ,

I am looking for best solution to map parent-child (one to many) dynamically in ElasticSearch .

I tried with join query , Parent Query ID , Bucket Aggregation but wish to avoid reindex and need the flexibility of adding relationship on the fly .

Request you to share best proven method known .

Thanks.

---

<div class="post-metadata">

**Author:** ![mikesparr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikesparr/32/4619_2.png) [@mikesparr](https://discuss.elastic.co/u/mikesparr)\
**Post date:** [August 6, 2018, 7:56pm UTC](https://discuss.elastic.co/t/mapping-relationship-dynamically-in-es-6-0/143205/2 "2018-08-06T19:56:15Z")

</div>

The `_parent` field was removed in favor of `join` as noted here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html)

---

<div class="post-metadata">

**Author:** ![pDonS](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@pDonS](https://discuss.elastic.co/u/pDonS)\
**Post date:** [August 6, 2018, 9:06pm UTC](https://discuss.elastic.co/t/mapping-relationship-dynamically-in-es-6-0/143205/3 "2018-08-06T21:06:09Z")

</div>

thanks a lot for your response .

Parent-join restrictions

It is possible to add a new relation to an existing join field.

does above action demand reindex ?

---

<div class="post-metadata">

**Author:** ![mikesparr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikesparr/32/4619_2.png) [@mikesparr](https://discuss.elastic.co/u/mikesparr)\
**Post date:** [August 6, 2018, 9:47pm UTC](https://discuss.elastic.co/t/mapping-relationship-dynamically-in-es-6-0/143205/4 "2018-08-06T21:47:03Z")

</div>

I'm not sure offhand but that should be easy to test. I have updated mappings and templates before without reindex and subsequent records applied new settings. Try and the response messages will tell you if you can or cannot 😉

---

<div class="post-metadata">

**Author:** ![pDonS](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@pDonS](https://discuss.elastic.co/u/pDonS)\
**Post date:** [August 8, 2018, 9:28pm UTC](https://discuss.elastic.co/t/mapping-relationship-dynamically-in-es-6-0/143205/5 "2018-08-08T21:28:33Z")

</div>

Basically, I wish to achieve below use case . Thanks a lot for your valuable inputs

Need the ability to create new metadata on top of Elastic documents without having to re-index. The latter is a veeeery slow operation given the amount of data  
The metadata needs to be available for joins. Assume I have ingested documents of type Doc with a field name  
i. I can create a metadata called Altin, which has a score. I can then do select all Doc d, where d. name=’Joe’ and metadata m.name=’Altin’ and m.parent=d.id and m.score\>9

```
                                                         ii. I can create a metadata called Vassil which has a color. I can then do select all Doc d, where d. name=’Joe’ and metadata m.name=’Vassil’ m.parent=d.id and m.color=’red’

                                                       iii. And I can combine select all Doc d, where d. name=’Joe’ and metadata m, m.name=’Vassil’ m.parent=d.id and m.color=’red’ and m.score=3
```

---

<div class="post-metadata">

**Author:** ![pDonS](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@pDonS](https://discuss.elastic.co/u/pDonS)\
**Post date:** [August 9, 2018, 2:17pm UTC](https://discuss.elastic.co/t/mapping-relationship-dynamically-in-es-6-0/143205/6 "2018-08-09T14:17:22Z")

</div>

@dakrone @darkmoon @Akhilesh-Tiwari

---

<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:** [September 6, 2018, 2:17pm UTC](https://discuss.elastic.co/t/mapping-relationship-dynamically-in-es-6-0/143205/7 "2018-09-06T14:17:28Z")

</div>

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