# Rolling index with parent/child?

**URL:** https://discuss.elastic.co/t/rolling-index-with-parent-child/49237
**Category:** Elasticsearch
**Created:** [May 4, 2016, 10:51pm UTC](https://discuss.elastic.co/t/rolling-index-with-parent-child/49237 "2016-05-04T22:51:47Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kucera.jan.cz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kucera.jan.cz/32/5869_2.png) [@kucera.jan.cz](https://discuss.elastic.co/u/kucera.jan.cz)
#### Post date: [May 4, 2016, 10:51pm UTC](https://discuss.elastic.co/t/rolling-index-with-parent-child/49237/1 "2016-05-04T22:51:47Z")

</div>

Hello everyone,

I was wondering whether there is a possibility to have rolling index (time based) with parent/child relationship.  
I am indexing time based data (index per day, all aliased) and all docs are related to one parent with ID. Users than can in any time label each parent and I would need to search (and aggregate) all child docs with certain labels.

Is there any other possibility than [Application-side joins](https://www.elastic.co/guide/en/elasticsearch/guide/current/application-joins.html) ?

Thanks in advance  
Jan

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [May 4, 2016, 11:03pm UTC](https://discuss.elastic.co/t/rolling-index-with-parent-child/49237/2 "2016-05-04T23:03:12Z")

</div>

You can do this, children can refer to a non-existent parent.

---

<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: [May 5, 2016, 5:28am UTC](https://discuss.elastic.co/t/rolling-index-with-parent-child/49237/3 "2016-05-05T05:28:45Z")

</div>

Parent/child is as you point out very difficult to use with time-based indices due to the limitations that the parent need to be in the same shard as the children, thereby requiring a parent per time-based index in order for filtering on parent fields to work. Depending on the number of children per parent and the frequency at which parent tags change, denormalisation and/or application side joins are generally the best way to go.

---

<div class="post-metadata">

### Author: ![kucera.jan.cz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kucera.jan.cz/32/5869_2.png) [@kucera.jan.cz](https://discuss.elastic.co/u/kucera.jan.cz)
#### Post date: [May 5, 2016, 5:46am UTC](https://discuss.elastic.co/t/rolling-index-with-parent-child/49237/4 "2016-05-05T05:46:56Z")

</div>

Hello @Christian_Dahlqvist,

thank you for your answer. The frequency of parent tagging can be hundreds per minute. However I need to apply that tag for ALL docs in the cluster that are related to the parent.

If I understand correctly:  
2016-01-01 - I create child C1 with relation to A  
2016-01-02 - I create child C2 with relation to A

If user will tag parent A system needs to create/update parent document in both 2016-01-01 and 2016-01-02 indices, is that correct?

Also if next day someone will create new index (2016-01-03) I would be forced to insert parent doc A to this index too...?

Jan

---

<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: [May 5, 2016, 7:00am UTC](https://discuss.elastic.co/t/rolling-index-with-parent-child/49237/5 "2016-05-05T07:00:39Z")

</div>

If the update frequency is that high I suspect application-side join is the best 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 5, 2017, 10:53pm UTC](https://discuss.elastic.co/t/rolling-index-with-parent-child/49237/6 "2017-07-05T22:53:51Z")

</div>


