# How to set \_parent properly using Logstash 2.0

**URL:** <https://discuss.elastic.co/t/how-to-set--parent-properly-using-logstash-2-0/33497>\
**Category:** Logstash\
**Created:** [November 2, 2015, 10:30am UTC](https://discuss.elastic.co/t/how-to-set--parent-properly-using-logstash-2-0/33497 "2015-11-02T10:30:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![drdebian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drdebian/32/5622_2.png) [@drdebian](https://discuss.elastic.co/u/drdebian)\
**Post date:** [November 2, 2015, 10:30am UTC](https://discuss.elastic.co/t/how-to-set--parent-properly-using-logstash-2-0/33497/1 "2015-11-02T10:30:19Z")

</div>

I'm trying to load some tables from a relational database into ES 2.0 using logstash. I've created the apropriate mappings in ES to reflect the relationships between the tables (basically one is the parent with the other two pointing to it using \_parent)

Reading the tables with Logstash is no problem using JDBC, creating the the proper parent-child relationships, however, is. It appears that the Elasticsearch output plugin lacks the ability to properly pass along the parent-id field to the \_parent field in ES. In analogy to the "document\_id" or "routing" parameters, I would expect to be able to use a "parent" parameter, to which I can pass the value of the parent-id from the database table I'm reading in input.

I've been crawling up and down the web to find a workaround. Even though I found lots of suggestions, none of them seem to work with ES 2.0 anymore (including adding the \_parent field using filter/mutate/add\_field etc.).

Is there any hope for this parameter to be available anytime soon?

---

<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:** [November 3, 2015, 12:40am UTC](https://discuss.elastic.co/t/how-to-set--parent-properly-using-logstash-2-0/33497/2 "2015-11-03T00:40:26Z")

</div>

This may help a bit - [https://www.elastic.co/guide/en/elasticsearch/reference/current/\_mapping\_changes.html#migration-meta-fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/_mapping_changes.html#migration-meta-fields)

But LS doesn't work with parent/child at all.

---

<div class="post-metadata">

**Author:** ![drdebian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drdebian/32/5622_2.png) [@drdebian](https://discuss.elastic.co/u/drdebian)\
**Post date:** [November 3, 2015, 6:00am UTC](https://discuss.elastic.co/t/how-to-set--parent-properly-using-logstash-2-0/33497/3 "2015-11-03T06:00:54Z")

</div>

Thanks for the link. I understand the changes, but at the same time I see no solution unless logstash is enhanced with the ability to set the \_parent meta-field in the output.

I reverted to ES 1.7.3 now, where I can pass the \_parent field in the document body and in combination with routing the child to the right parent shard, it appears to work. Feels like a hack, however. 😄

On a side note, is it possible to have logstash generate a nested field from the child tables while reading the parent table using JDBC?

---

<div class="post-metadata">

**Author:** ![abhinavzspace](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@abhinavzspace](https://discuss.elastic.co/u/abhinavzspace)\
**Post date:** [March 19, 2017, 10:43am UTC](https://discuss.elastic.co/t/how-to-set--parent-properly-using-logstash-2-0/33497/4 "2017-03-19T10:43:56Z")

</div>

I am facing the same problem. Is there a work around now?

---

<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, 4:27am UTC](https://discuss.elastic.co/t/how-to-set--parent-properly-using-logstash-2-0/33497/5 "2017-07-06T04:27:45Z")

</div>


