# How can i merge 2 different types

**URL:** https://discuss.elastic.co/t/how-can-i-merge-2-different-types/107534
**Category:** Elasticsearch
**Created:** [November 14, 2017, 10:59am UTC](https://discuss.elastic.co/t/how-can-i-merge-2-different-types/107534 "2017-11-14T10:59:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sujoymondal87](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sujoymondal87/32/24184_2.png) [@sujoymondal87](https://discuss.elastic.co/u/sujoymondal87)
#### Post date: [November 14, 2017, 10:59am UTC](https://discuss.elastic.co/t/how-can-i-merge-2-different-types/107534/1 "2017-11-14T10:59:08Z")

</div>

I need to merge two different 'types' (or two different 'indexes', even if this is a less preferred method) in ElasticSearch 5.6  
This is the first type 'flag'  
{  
"\_index": "flags",  
"\_type": "flag",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"title" : "Sad title is here"  
"user\_id" : 2  
}  
}  
Here's the second 'user'  
{  
"\_index": "flags",  
"\_type": "user",  
"\_id": "2",  
"\_score": 1,  
"\_source": {  
"username" : "john doe"  
}  
}  
The value of 'user\_id' in type 'flag' is equal to the '\_id' of the second type named 'user'  
This is the result we're trying to get:  
{  
"\_index": "flags",  
"\_type": "flag",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"title" : "Sad title is here"  
"user\_id" : 2,  
"username" : 'john doe'  
}  
}  
If it is possible to get the result by using different indeces instead of 'types', that is ok as well, but less preferred.

---

<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: [November 14, 2017, 11:19am UTC](https://discuss.elastic.co/t/how-can-i-merge-2-different-types/107534/2 "2017-11-14T11:19:52Z")

</div>

Knowing that types are going to be removed I think it’s a good idea to do that.

This is something you need to solve IMO on the application side (ingestion side) or with an ETL.

---

<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: [December 12, 2017, 11:19am UTC](https://discuss.elastic.co/t/how-can-i-merge-2-different-types/107534/3 "2017-12-12T11:19:59Z")

</div>

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