# Sequential processing jdbc input to elastic search

**URL:** <https://discuss.elastic.co/t/sequential-processing-jdbc-input-to-elastic-search/170819>\
**Category:** Logstash\
**Created:** [March 5, 2019, 3:41am UTC](https://discuss.elastic.co/t/sequential-processing-jdbc-input-to-elastic-search/170819 "2019-03-05T03:41:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PagerBae](https://avatars.discourse-cdn.com/v4/letter/p/f0a364/32.png) [@PagerBae](https://discuss.elastic.co/u/PagerBae)\
**Post date:** [March 5, 2019, 3:41am UTC](https://discuss.elastic.co/t/sequential-processing-jdbc-input-to-elastic-search/170819/1 "2019-03-05T03:41:56Z")

</div>

Hi, I am new to logstash and elasticsearch.  
I have some separated jdbc query that can't be joined by SQL syntax (different source).

I want to process it in logstash in this sequential:  
Run Query A , check if query A result is not empty then run query B (example have field1, field2) and query C (field 1, field 3, field4).

Then data from query B and query C will be combined by data that have same id (field 1) so each data have: {field1, field2, field3, field4} and will be inserted to elasticsearch.

How to do this process in one logstash file?

```
input {
    #Query A
    jdbc {
    }
    #Query B
    jdbc {
    }
    #Query C
    jdbc {
    }
}

output {
  stdout{
        codec=>rubydebug{}
  }
  elasticsearch {
       hosts => "elasticsearch:9200"
       index => "product"
       document_type => "product"
       document_id => "%{product_number}"
       doc_as_upsert => true
  }
}
```

---

<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:** [April 2, 2019, 3:41am UTC](https://discuss.elastic.co/t/sequential-processing-jdbc-input-to-elastic-search/170819/2 "2019-04-02T03:41:56Z")

</div>

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