# Elasticsearch support join on tables or not?

**URL:** <https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654>\
**Category:** Elasticsearch\
**Created:** [January 16, 2018, 7:36am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654 "2018-01-16T07:36:59Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![hasti\_gh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hasti_gh/32/28165_2.png) [@hasti\_gh](https://discuss.elastic.co/u/hasti_gh)\
**Post date:** [January 16, 2018, 7:37am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/1 "2018-01-16T07:37:09Z")

</div>

iam really confiused . if elasticsearch have not join what is this plugins that can support join on elasticsearch for example:

> **[Relational Joins for Elasticsearch: the SIREn Join Plugin](https://siren.io/relational-joins-for-elasticsearch-the-siren-join-plugin/)**
>
> We are very very happy to announce today the general availability of SIREn Join, an open source plugin for Elasticsearch...

  
someone explain more about join in elasticsearch.  
thanx

---

<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:** [January 16, 2018, 7:42am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/2 "2018-01-16T07:42:48Z")

</div>

Elasticsearch has no SQL-like joins.  
Plugins like this one do it in memory, which can lead to scalability restrictions.

---

<div class="post-metadata">

**Author:** ![hasti\_gh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hasti_gh/32/28165_2.png) [@hasti\_gh](https://discuss.elastic.co/u/hasti_gh)\
**Post date:** [January 16, 2018, 7:47am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/3 "2018-01-16T07:47:02Z")

</div>

hi thanx .  
but join for programmers is very usefull .for example many to many and one to many joins. how elasticsearch support these joins.  
excuse me for my question i have not very much experiment in elasticsearch.

---

<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:** [January 16, 2018, 7:47am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/4 "2018-01-16T07:47:44Z")

</div>

Elasticsearch is a NoSQL, distributed system. Distributed joins are not easy to do.

---

<div class="post-metadata">

**Author:** ![hasti\_gh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hasti_gh/32/28165_2.png) [@hasti\_gh](https://discuss.elastic.co/u/hasti_gh)\
**Post date:** [January 16, 2018, 7:51am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/5 "2018-01-16T07:51:23Z")

</div>

elasticsearch is NoSql database and it means not only SQL . and it means its more than SQL. for these reasons i cant beileve that elasticsearch cant support joins....

---

<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:** [January 16, 2018, 7:53am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/6 "2018-01-16T07:53:54Z")

</div>

> [@hasti\_gh](#):
>
> and it means its more than SQL

It means it's different.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 16, 2018, 8:16am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/7 "2018-01-16T08:16:24Z")

</div>

And it means that you need to forget what you learned about SQL and learn how to work with Document databases or document search engines.

Basically, you need probably to denormalize your documents.

May be we can help if you explain the kind of data you have, like with some examples and why do you think you need "join"?

---

<div class="post-metadata">

**Author:** ![hasti\_gh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hasti_gh/32/28165_2.png) [@hasti\_gh](https://discuss.elastic.co/u/hasti_gh)\
**Post date:** [January 16, 2018, 9:22am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/8 "2018-01-16T09:22:07Z")

</div>

i have a model : CmsCard.java  
that this model has this field :

```
private List<CmsCardSecondaryAccount> subDeposits = new ArrayList<CmsCardSecondaryAccount>();

```

in my CmsCardSecondaryAccount.java model i have id , code,name, cardId and ....

in my java code i have a search method. i wanna search cards that the name or code of their CmsCardSecondaryAccount is something for example code = 123 and name = "debit".

i first load all CmsCardSecondaryAccount that has same CardId and then with queries in elasticsearch do my solution.but i wanna handle this with something like joinQuery...and something in elasticsearch .i dont want handle this in my bussiness.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 16, 2018, 10:17am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/9 "2018-01-16T10:17:46Z")

</div>

The main question you have to ask yourself are:

- What my users are looking for?
- What are the fields they need to search for those objects

If your users are searching for deposits, then index deposits. If a user needs to find a deposit where the card name is `foo`, then just add to the deposit object the field `"card_name": "foo"` and you're done.

I'm not saying that it's easy but when you want to use a technology, you need to embrace how it has been designed.

Actually that was my past experience when I added elasticsearch on top of a relational DB with the same kind of Java code behind the scene.

My 2 cents

---

<div class="post-metadata">

**Author:** ![hasti\_gh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hasti_gh/32/28165_2.png) [@hasti\_gh](https://discuss.elastic.co/u/hasti_gh)\
**Post date:** [January 20, 2018, 7:53am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/10 "2018-01-20T07:53:25Z")

</div>

thanx for reply.but i have my problem yet... what kind of join elasticsearch support??? ok i dont look at elasticsearch with my vision of SQL . i know it has document base search. how can we join in document base search??  
in parent and child filters that in learn of elasticsearch site said they are join queries what are those?? how can use those queries as join query???

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 20, 2018, 8:31am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/11 "2018-01-20T08:31:26Z")

</div>

Yes you can use parent / child feature.

You can read this as an introduction [https://www.elastic.co/guide/en/elasticsearch/guide/2.x/parent-child.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/parent-child.html) But it's not compatible with 6.x yet. So then read [https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html)

---

<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:** [February 17, 2018, 8:31am UTC](https://discuss.elastic.co/t/elasticsearch-support-join-on-tables-or-not/115654/12 "2018-02-17T08:31:37Z")

</div>

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