# Parent / child relation

**URL:** <https://discuss.elastic.co/t/parent-child-relation/16925>\
**Category:** Elasticsearch\
**Created:** [April 10, 2014, 1:50pm UTC](https://discuss.elastic.co/t/parent-child-relation/16925 "2014-04-10T13:50:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Janis\_Gruzis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/janis_gruzis/32/1659_2.png) [@Janis\_Gruzis](https://discuss.elastic.co/u/Janis_Gruzis)\
**Post date:** [April 10, 2014, 1:50pm UTC](https://discuss.elastic.co/t/parent-child-relation/16925/1 "2014-04-10T13:50:14Z")

</div>

Hello,

im trying to create ElasticSearch mapping in Symfony 2 with help of  
FOSElasticaBundle. Well it probably is not relevant that I use Symfony 2,  
but relevant is the fact that Im trying to create mapping as similar to  
MySQL schema as I can. I stumbled upon situation, where I have foreign key,  
which can be null. As far as I know there are multiple ways to implement  
foreign key in ElasticSearch, I chose child/parent approach. Can I  
implement in this approach the null foreign key which would mean that type  
would have defined parent, but in some cases parent wouldnt exist?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Mandar\_Rahurkar](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mandar\_Rahurkar](https://discuss.elastic.co/u/Mandar_Rahurkar)\
**Post date:** [April 10, 2014, 3:47pm UTC](https://discuss.elastic.co/t/parent-child-relation/16925/2 "2014-04-10T15:47:47Z")

</div>

This should be fine.  
You can always de-normalize your MySQL scheme in your elasticsearch indexes.

On Thu, Apr 10, 2014 at 6:50 AM, Janis Gruzis [jgruzis@gmail.com](mailto:jgruzis@gmail.com) wrote:

> Hello,
> 
> im trying to create Elasticsearch mapping in Symfony 2 with help of  
> FOSElasticaBundle. Well it probably is not relevant that I use Symfony 2,  
> but relevant is the fact that Im trying to create mapping as similar to  
> MySQL schema as I can. I stumbled upon situation, where I have foreign key,  
> which can be null. As far as I know there are multiple ways to implement  
> foreign key in Elasticsearch, I chose child/parent approach. Can I  
> implement in this approach the null foreign key which would mean that type  
> would have defined parent, but in some cases parent wouldnt exist?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CANL9KRJWm4iv0FTg926wQ%2BTUWCYRo-NVOoxCM18v0vErxrVZ4Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CANL9KRJWm4iv0FTg926wQ%2BTUWCYRo-NVOoxCM18v0vErxrVZ4Q%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Janis\_Gruzis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/janis_gruzis/32/1659_2.png) [@Janis\_Gruzis](https://discuss.elastic.co/u/Janis_Gruzis)\
**Post date:** [April 10, 2014, 4:50pm UTC](https://discuss.elastic.co/t/parent-child-relation/16925/3 "2014-04-10T16:50:04Z")

</div>

Yes that is an option, but the question was specific - is there a way to  
add document to type which does not contain parent, if in mapping there is  
parent for that type, like relational DB null reference.

ceturtdiena, 2014. gada 10. aprīlis 18:47:47 UTC+3, Mandar Rahurkar  
rakstīja:

> This should be fine.  
> You can always de-normalize your MySQL scheme in your elasticsearch  
> indexes.
> 
> On Thu, Apr 10, 2014 at 6:50 AM, Janis Gruzis \<[jgr...@gmail.com](mailto:jgr...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hello,
> > 
> > im trying to create Elasticsearch mapping in Symfony 2 with help of  
> > FOSElasticaBundle. Well it probably is not relevant that I use Symfony 2,  
> > but relevant is the fact that Im trying to create mapping as similar to  
> > MySQL schema as I can. I stumbled upon situation, where I have foreign key,  
> > which can be null. As far as I know there are multiple ways to implement  
> > foreign key in Elasticsearch, I chose child/parent approach. Can I  
> > implement in this approach the null foreign key which would mean that type  
> > would have defined parent, but in some cases parent wouldnt exist?
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/353046c4-184c-4431-bf60-4c1747470c95%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0deb5aac-08b3-4ae7-b523-37cd602a6ae6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0deb5aac-08b3-4ae7-b523-37cd602a6ae6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:36am UTC](https://discuss.elastic.co/t/parent-child-relation/16925/4 "2017-07-06T01:36:50Z")

</div>

Closed on July 6, 2017, 1:36am UTC


