# Strategy for Input join parent child relation with two statements?

**URL:** <https://discuss.elastic.co/t/strategy-for-input-join-parent-child-relation-with-two-statements/229796>\
**Category:** Logstash\
**Created:** [April 25, 2020, 10:19pm UTC](https://discuss.elastic.co/t/strategy-for-input-join-parent-child-relation-with-two-statements/229796 "2020-04-25T22:19:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Narciso\_Parra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narciso_parra/32/67124_2.png) [@Narciso\_Parra](https://discuss.elastic.co/u/Narciso_Parra)\
**Post date:** [April 25, 2020, 10:19pm UTC](https://discuss.elastic.co/t/strategy-for-input-join-parent-child-relation-with-two-statements/229796/1 "2020-04-25T22:19:25Z")

</div>

Hi I need to Sync Postgres with Elasticsearch. I used jdbc\_input\_plugin and these is the main idea:

- I have a index with parent child relation join type
- I have one querys for index parents: (users)
- I have second query for indexing childs (insights)

- Can't go with one query cause is to expensive in performance for postgres.

The process is:

1. Index all the parent and then sync with updated\_at  
2 Indexing all the childs an then sync with updated\_at

The second query depend on the query 1 has already executed. because we we don't want to index children without parents.

Is possible to stop the second input query until que first has already indexing?  
If yes how to do this?

Or there is another strategy?  
I will appreciate your response

---

<div class="post-metadata">

**Author:** ![Narciso\_Parra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narciso_parra/32/67124_2.png) [@Narciso\_Parra](https://discuss.elastic.co/u/Narciso_Parra)\
**Post date:** [April 25, 2020, 11:38pm UTC](https://discuss.elastic.co/t/strategy-for-input-join-parent-child-relation-with-two-statements/229796/2 "2020-04-25T23:38:57Z")

</div>

Update: Order of indexing parent and childs documents there is no necessary.

There is no problem with indexing childs document without already indexed the parent.  
When the parent is indexing later the query works without problem.

---

<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:** [May 23, 2020, 11:39pm UTC](https://discuss.elastic.co/t/strategy-for-input-join-parent-child-relation-with-two-statements/229796/3 "2020-05-23T23:39:02Z")

</div>

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