# Join two indices using alias

**URL:** https://discuss.elastic.co/t/join-two-indices-using-alias/162490
**Category:** Elasticsearch
**Created:** [December 31, 2018, 9:49am UTC](https://discuss.elastic.co/t/join-two-indices-using-alias/162490 "2018-12-31T09:49:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://discuss.elastic.co/u/Loki)
#### Post date: [December 31, 2018, 9:49am UTC](https://discuss.elastic.co/t/join-two-indices-using-alias/162490/1 "2018-12-31T09:49:03Z")

</div>

Hi,  
I am still newbie in elasticsearch and I have also read that we cannot join two indices.  
But is it possible to use alias in this case? I mean, can we join indices using alias?  
Or is there any alternative or workaround for this?

Thanks,  
Loki

---

<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: [December 31, 2018, 9:50am UTC](https://discuss.elastic.co/t/join-two-indices-using-alias/162490/2 "2018-12-31T09:50:46Z")

</div>

You can query across multiple indices by specifying multiple index names or using aliases, but Elasticsearch does not support joins. It would be easier to help if you could describe what your data looks like and what you are trying to do.

---

<div class="post-metadata">

### Author: ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://discuss.elastic.co/u/Loki)
#### Post date: [December 31, 2018, 10:02am UTC](https://discuss.elastic.co/t/join-two-indices-using-alias/162490/3 "2018-12-31T10:02:36Z")

</div>

My POCO data looks something like below

```
Employee 
{
Employee_ID int;
First_Name string;
Last_Name string;
Dept_ID int;
}

Department
{
Dept_ID int;
Dept_Name string;
Dept_Region string;
}

```

I was hoping to create two indices for Employee and Department and join using Dept\_ID in order to get all records from both the indices.

---

<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: [December 31, 2018, 10:05am UTC](https://discuss.elastic.co/t/join-two-indices-using-alias/162490/4 "2018-12-31T10:05:07Z")

</div>

That kind of joins is not supported in Elasticsearch. A common way to get around this would be to denormalise the data and store department information with the employee.

---

<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: [January 28, 2019, 10:05am UTC](https://discuss.elastic.co/t/join-two-indices-using-alias/162490/5 "2019-01-28T10:05:13Z")

</div>

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