# Merge 2 types based on common field

**URL:** https://discuss.elastic.co/t/merge-2-types-based-on-common-field/16669
**Category:** Elasticsearch
**Created:** [March 28, 2014, 7:42am UTC](https://discuss.elastic.co/t/merge-2-types-based-on-common-field/16669 "2014-03-28T07:42:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Fawad\_Shah](https://avatars.discourse-cdn.com/v4/letter/f/6bbea6/32.png) [@Fawad\_Shah](https://discuss.elastic.co/u/Fawad_Shah)
#### Post date: [March 28, 2014, 7:42am UTC](https://discuss.elastic.co/t/merge-2-types-based-on-common-field/16669/1 "2014-03-28T07:42:01Z")

</div>

Hi,

I have an index named 'product' it has two types named 'type1' and 'type2'

For example:

_{ product\_id: "1111", price: "23.56", stock: "100" }_

_{ product\_id: "1111", category: "iPhone case", manufacturer: "Belkin" }_

I want them to join based on 'product\_id' and index them in either new  
index or new type in same 'product' index, so eventually it should look  
like this.

_{ product\_id: "1111", price: "23.56", stock: "100" category: "iPhone  
case", manufacturer: "Belkin" }_

FYI,

- I have millions of records similar to above, so finally I will be doing  
the similar thing for all.
- I am using ELK stack.
- My end goal is to display the combined result of above 2 types in Kibana.

My question is similar to this[http://elasticsearch-users.115913.n3.nabble.com/Combining-fields-from-various-indexes-td4031116.html](http://elasticsearch-users.115913.n3.nabble.com/Combining-fields-from-various-indexes-td4031116.html) but  
the person reported this question have 2 separate indexes while I have one  
index but 2 separate types.

Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d1a30f9a-ee37-49b4-85ac-1be5d5fe6ca8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1a30f9a-ee37-49b4-85ac-1be5d5fe6ca8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [March 28, 2014, 8:41am UTC](https://discuss.elastic.co/t/merge-2-types-based-on-common-field/16669/2 "2014-03-28T08:41:10Z")

</div>

You can not JOIN.

You should design your model to fit to your needs. I mean that you should index documents like:

{  
product\_id: "1111",  
price: "23.56",  
stock: "100"  
category: "iPhone case",  
manufacturer: "Belkin"  
}

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 28 mars 2014 à 08:42:04, Fawad Shah ([fawadshah123@gmail.com](mailto:fawadshah123@gmail.com)) a écrit:

Hi,

I have an index named 'product' it has two types named 'type1' and 'type2'

For example:  
{  
product\_id: "1111",  
price: "23.56",  
stock: "100"  
}

{  
product\_id: "1111",  
category: "iPhone case",  
manufacturer: "Belkin"  
}

I want them to join based on 'product\_id' and index them in either new index or new type in same 'product' index, so eventually it should look like this.

{  
product\_id: "1111",  
price: "23.56",  
stock: "100"  
category: "iPhone case",  
manufacturer: "Belkin"  
}

FYI,

- I have millions of records similar to above, so finally I will be doing the similar thing for all.
- I am using ELK stack.
- My end goal is to display the combined result of above 2 types in Kibana.

My question is similar to this but the person reported this question have 2 separate indexes while I have one index but 2 separate types.

## Thanks!

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d1a30f9a-ee37-49b4-85ac-1be5d5fe6ca8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1a30f9a-ee37-49b4-85ac-1be5d5fe6ca8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.533535a6.216231b.161d2%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.533535a6.216231b.161d2%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Fawad\_Shah](https://avatars.discourse-cdn.com/v4/letter/f/6bbea6/32.png) [@Fawad\_Shah](https://discuss.elastic.co/u/Fawad_Shah)
#### Post date: [March 28, 2014, 9:29am UTC](https://discuss.elastic.co/t/merge-2-types-based-on-common-field/16669/3 "2014-03-28T09:29:18Z")

</div>

Thanks David for your reply,  
This means I _don't have any other option_ than redesign my index model ?  
Would you suggest me any alternate option, FYI I am using ELK stack.

Thanks!

On Fri, Mar 28, 2014 at 1:41 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> You can not JOIN.
> 
> You should design your model to fit to your needs. I mean that you should  
> index documents like:
> 
> {  
> product\_id: "1111",  
> price: "23.56",  
> stock: "100"  
> category: "iPhone case",  
> manufacturer: "Belkin"  
> }
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 28 mars 2014 à 08:42:04, Fawad Shah ([fawadshah123@gmail.com](mailto:fawadshah123@gmail.com)) a écrit:
> 
> Hi,
> 
> I have an index named 'product' it has two types named 'type1' and  
> 'type2'
> 
> For example:
> 
> - { product\_id: "1111", price: "23.56", stock: "100" }\*
> 
> - { product\_id: "1111", category: "iPhone case", manufacturer:  
> "Belkin" }\*
> 
> I want them to join based on 'product\_id' and index them in either new  
> index or new type in same 'product' index, so eventually it should look  
> like this.
> 
> - { product\_id: "1111", price: "23.56", stock: "100" category: "iPhone  
> case", manufacturer: "Belkin" }\*
> 
> FYI,
> 
> - I have millions of records similar to above, so finally I will be doing  
> the similar thing for all.
> - I am using ELK stack.
> - My end goal is to display the combined result of above 2 types in  
> Kibana.
> 
> My question is similar to this[http://elasticsearch-users.115913.n3.nabble.com/Combining-fields-from-various-indexes-td4031116.html](http://elasticsearch-users.115913.n3.nabble.com/Combining-fields-from-various-indexes-td4031116.html) but  
> the person reported this question have 2 separate indexes while I have one  
> index but 2 separate types.
> 
> ## Thanks!
> 
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).
> 
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/d1a30f9a-ee37-49b4-85ac-1be5d5fe6ca8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1a30f9a-ee37-49b4-85ac-1be5d5fe6ca8%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/d1a30f9a-ee37-49b4-85ac-1be5d5fe6ca8%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d1a30f9a-ee37-49b4-85ac-1be5d5fe6ca8%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/VRUCQArcQas/unsubscribe](https://groups.google.com/d/topic/elasticsearch/VRUCQArcQas/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/etPan.533535a6.216231b.161d2%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.533535a6.216231b.161d2%40MacBook-Air-de-David.local)[https://groups.google.com/d/msgid/elasticsearch/etPan.533535a6.216231b.161d2%40MacBook-Air-de-David.local?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/etPan.533535a6.216231b.161d2%40MacBook-Air-de-David.local?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAD32Vm3PyfQJkH7LKk8Co6nEr%2BHkTxH3\_2PNcDG9%2Bz--i%2B2mLA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAD32Vm3PyfQJkH7LKk8Co6nEr%2BHkTxH3_2PNcDG9%2Bz--i%2B2mLA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [July 6, 2017, 1:39am UTC](https://discuss.elastic.co/t/merge-2-types-based-on-common-field/16669/4 "2017-07-06T01:39:57Z")

</div>


