# Merge indexes

**URL:** https://discuss.elastic.co/t/merge-indexes/130254
**Category:** Elasticsearch
**Created:** [May 2, 2018, 1:17pm UTC](https://discuss.elastic.co/t/merge-indexes/130254 "2018-05-02T13:17:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Pierre2](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pierre2](https://discuss.elastic.co/u/Pierre2)
#### Post date: [May 2, 2018, 1:17pm UTC](https://discuss.elastic.co/t/merge-indexes/130254/1 "2018-05-02T13:17:38Z")

</div>

Hello,

I have got two types of log files that contains differents information about calls so I got two indexes. The common field between the two files types is the call id that is unique. I want to create a new index that will contains some fileds obtained by the first index and some others obtains by the other index. It's that possible ?

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [May 2, 2018, 1:38pm UTC](https://discuss.elastic.co/t/merge-indexes/130254/2 "2018-05-02T13:38:30Z")

</div>

You can use the scroll API to query across both indices using a `sort` on the common ID field and in your client code (python, whatever) you can fuse the docs together into a new one you insert into a new index

---

<div class="post-metadata">

### Author: ![mjunaidmuzammil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mjunaidmuzammil/32/56910_2.png) [@mjunaidmuzammil](https://discuss.elastic.co/u/mjunaidmuzammil)
#### Post date: [May 2, 2018, 2:04pm UTC](https://discuss.elastic.co/t/merge-indexes/130254/3 "2018-05-02T14:04:40Z")

</div>

Alternatively if you are searching on the basis of those common parameters, you can make use of the multi search API ([https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html)). The documents can be fused together at the application layer.

---

<div class="post-metadata">

### Author: ![Pierre2](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pierre2](https://discuss.elastic.co/u/Pierre2)
#### Post date: [May 3, 2018, 6:36am UTC](https://discuss.elastic.co/t/merge-indexes/130254/4 "2018-05-03T06:36:40Z")

</div>

Thank you for answers but I don't understand what I should do to merge my two indexes. My first index is cdr\_sbc and my second is cdr\_oem. I want to automatically create a new index that will contains some fields from cdr\_sbc and some from cdr\_oem. The common field is Call\_id. For example if cdr\_sbc contains these fields :

> "call station", "called station", "Call\_id"

and the cdr\_oem contains

> "call\_time", "codec", "media type", "Call\_id".

I want to automatically build a new index called for exemaple index3 that will contains

> "call station", "called station", "call\_time", "codec", "media type", "Call\_id".

---

<div class="post-metadata">

### Author: ![mjunaidmuzammil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mjunaidmuzammil/32/56910_2.png) [@mjunaidmuzammil](https://discuss.elastic.co/u/mjunaidmuzammil)
#### Post date: [May 3, 2018, 7:27am UTC](https://discuss.elastic.co/t/merge-indexes/130254/5 "2018-05-03T07:27:50Z")

</div>

I haven't seen any API yet that provides this functionality. For this functionality, you need to write a logic that pulls documents, combines them and them pushes the combined one into another index.

---

<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: [May 31, 2018, 7:27am UTC](https://discuss.elastic.co/t/merge-indexes/130254/6 "2018-05-31T07:27:57Z")

</div>

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