# Merging Two Indexes

**URL:** <https://discuss.elastic.co/t/merging-two-indexes/8745>\
**Category:** Elasticsearch\
**Created:** [August 15, 2012, 6:24am UTC](https://discuss.elastic.co/t/merging-two-indexes/8745 "2012-08-15T06:24:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sumit\_Guptaa](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Sumit\_Guptaa](https://discuss.elastic.co/u/Sumit_Guptaa)\
**Post date:** [August 15, 2012, 6:24am UTC](https://discuss.elastic.co/t/merging-two-indexes/8745/1 "2012-08-15T06:24:11Z")

</div>

Hi all,

Can anybody tell me how we can merge two indicies..is there any mechanism in ES for merging index ....any help would be highly appreciated....Thanx

first index=\>

{"message":"abc"}  
{"message""def"}

Second Index=\>

{"name":"sumit"}  
{"name":"gupta"}

Regards,  
Sumit Gupta

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [August 15, 2012, 10:56am UTC](https://discuss.elastic.co/t/merging-two-indexes/8745/2 "2012-08-15T10:56:01Z")

</div>

Hi,

what exactly do you mean by merging indices?

If you have an index A and index B and you want to have new index C with  
would contain content from both indices A and B (and then you eventually  
want to drop indices A and B) then such merging is not supported by ES out  
of the box. But you can write a simple script to do it manually on your  
side (pull all data from index A and index into C, pull all data from index  
B and index into C, done).

If you just want to search across both indices A and B (as is they were a  
single index C) then you can of course do it (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/multi-index.html) or  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html)  
).

Regards,  
Lukas

On Wed, Aug 15, 2012 at 8:24 AM, Sumit Guptaa [sumit.gupta.ngi@gmail.com](mailto:sumit.gupta.ngi@gmail.com)wrote:

> Hi all,
> 
> Can anybody tell me how we can merge two indicies..is there any mechanism  
> in  
> ES for merging index ....any help would be highly appreciated....Thanx
> 
> first index=\>
> 
> {"message":"abc"}  
> {"message""def"}
> 
> Second Index=\>
> 
> {"name":"sumit"}  
> {"name":"gupta"}
> 
> Regards,  
> Sumit Gupta
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Merging-Two-Indexes-tp4021708.html](http://elasticsearch-users.115913.n3.nabble.com/Merging-Two-Indexes-tp4021708.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)\
**Post date:** [August 15, 2012, 12:35pm UTC](https://discuss.elastic.co/t/merging-two-indexes/8745/3 "2012-08-15T12:35:32Z")

</div>

Lukas is of course right, the easiest solution is to search over both  
indices. Alternativly you can pull documents out of both indices and throw  
them in a new one. But be careful with this solution: it does not work when  
you exclude source fields, as these can not be retrieved again.

Am Mittwoch, 15. August 2012 12:56:01 UTC+2 schrieb Lukáš Vlček:

> Hi,
> 
> what exactly do you mean by merging indices?
> 
> If you have an index A and index B and you want to have new index C with  
> would contain content from both indices A and B (and then you eventually  
> want to drop indices A and B) then such merging is not supported by ES out  
> of the box. But you can write a simple script to do it manually on your  
> side (pull all data from index A and index into C, pull all data from index  
> B and index into C, done).
> 
> If you just want to search across both indices A and B (as is they were a  
> single index C) then you can of course do it (  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/multi-index.html) or  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html)  
> ).
> 
> Regards,  
> Lukas
> 
> On Wed, Aug 15, 2012 at 8:24 AM, Sumit Guptaa \<[sumit.g...@gmail.com](mailto:sumit.g...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi all,
> > 
> > Can anybody tell me how we can merge two indicies..is there any mechanism  
> > in  
> > ES for merging index ....any help would be highly appreciated....Thanx
> > 
> > first index=\>
> > 
> > {"message":"abc"}  
> > {"message""def"}
> > 
> > Second Index=\>
> > 
> > {"name":"sumit"}  
> > {"name":"gupta"}
> > 
> > Regards,  
> > Sumit Gupta
> > 
> > --  
> > View this message in context:  
> > [http://elasticsearch-users.115913.n3.nabble.com/Merging-Two-Indexes-tp4021708.html](http://elasticsearch-users.115913.n3.nabble.com/Merging-Two-Indexes-tp4021708.html)  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> > 
> > --

--

---

<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, 3:16am UTC](https://discuss.elastic.co/t/merging-two-indexes/8745/4 "2017-07-06T03:16:18Z")

</div>


