# Can we use SQL Join in elastic query?

**URL:** <https://discuss.elastic.co/t/can-we-use-sql-join-in-elastic-query/196378>\
**Category:** Elasticsearch\
**Created:** [August 22, 2019, 5:58pm UTC](https://discuss.elastic.co/t/can-we-use-sql-join-in-elastic-query/196378 "2019-08-22T17:58:52Z")\
**Posts on this page:** 1\
**Showing post:** 14

<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:** [August 23, 2019, 5:00am UTC](https://discuss.elastic.co/t/can-we-use-sql-join-in-elastic-query/196378/14 "2019-08-23T05:00:28Z")

</div>

To do this at index time you probably need to send the data through Logstash as that offers greater flexibility. If it is truly a 1:1 mapping and the user name does not appear in multiple documents, you could set the document ID to the user name and perform an upsert (think Logstash supports this but have not tried) for both documents. You should then end up with a single document containing all the fields. Another option might be to use the aggregate filter, similar to what is described in [this thread](https://discuss.elastic.co/t/aggregation-filter-timeout-settings/196208/4).

I would recommend opening a separate thread on this in the Logstash section.

---

_[View the full topic](https://discuss.elastic.co/t/can-we-use-sql-join-in-elastic-query/196378)._
