# Join and merge documents

**URL:** <https://discuss.elastic.co/t/join-and-merge-documents/19245>\
**Category:** Elasticsearch\
**Created:** [August 13, 2014, 9:01am UTC](https://discuss.elastic.co/t/join-and-merge-documents/19245 "2014-08-13T09:01:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tao\_hiko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tao_hiko/32/707_2.png) [@tao\_hiko](https://discuss.elastic.co/u/tao_hiko)\
**Post date:** [August 13, 2014, 9:01am UTC](https://discuss.elastic.co/t/join-and-merge-documents/19245/1 "2014-08-13T09:01:08Z")

</div>

Hi All,

My background is DBA (RDBMS) and starter for elasticsearch.  
My question may duplicate to another question but I cannot find the answer  
correctly.

My environment, I have 2 indexes and 1 document in each index as below

index : ind1  
type : doc1  
\_id : running number not automatic generate id (1,2,3....xx)  
name : string  
status : string  
last\_update : date

index : ind2  
type : doc2  
\_id : automatic generate id  
doc\_id : number  
status : string  
last\_update : date

The relation is ind1.doc1.\_id = ind2.doc2.doc\_id.

My purpose, I need to insert data from ind2.doc2 into ind1doc1 when it  
doesn't exists in ind1.doc1 and update status and last\_update fields when  
it exist.

So Parent/Child method cannot use because data has been loaded to both  
tables already.

Could you please advise me in this case? and Is this possible to use  
aggregation or nested method across index? if not, How to join and merge  
data in same index?

Thank you,  
Hiko

--  
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/abedffe2-f301-4255-8c2a-d3b89c74b585%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/abedffe2-f301-4255-8c2a-d3b89c74b585%40googlegroups.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:09am UTC](https://discuss.elastic.co/t/join-and-merge-documents/19245/2 "2017-07-06T01:09:02Z")

</div>


