# Add any 2 Index to form new index which will combined data and should not override any fields values

**URL:** https://discuss.elastic.co/t/add-any-2-index-to-form-new-index-which-will-combined-data-and-should-not-override-any-fields-values/326173
**Category:** Kibana
**Tags:** reindex
**Created:** [February 22, 2023, 11:49am UTC](https://discuss.elastic.co/t/add-any-2-index-to-form-new-index-which-will-combined-data-and-should-not-override-any-fields-values/326173 "2023-02-22T11:49:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Mangesh\_Mathe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mangesh_mathe/32/103371_2.png) [@Mangesh\_Mathe](https://discuss.elastic.co/u/Mangesh_Mathe)
#### Post date: [February 22, 2023, 11:49am UTC](https://discuss.elastic.co/t/add-any-2-index-to-form-new-index-which-will-combined-data-and-should-not-override-any-fields-values/326173/1 "2023-02-22T11:49:53Z")

</div>

Hello All,

I want to merge two Index with same structure , which will create 3rd Index without overriding field values.  
For example:  
index\_1:  
"businessUnits": "FR,JP,IE"

index\_2:  
"businessUnits": "FR,GB,DE"

If I merge index\_1 and index\_2 using reindex API, It should not override values.  
Ii should give output as : "businessUnits": "FR,JP,IE,FR,GB,DE"

```auto
PUT emea_test/_doc/871123365V

{
  "type": "db-poc-user",
  "skuNum": " 871123365V",
  "businessUnits": "FR,JP,IE",
  "businessUnitsWithNames": [
    "[FR] France",
    "[JP] Japan",
    "[IE] Ireland"
  ],
  "@timestamp": "2020-07-22T04:12:00.376Z"
}

 ==================================

 

PUT global_test/_doc/871123365V
{
  "type": "db-test-user",
  "skuNum": " 871123365V",
  "businessUnits": "FR,GB,DE",
  "businessUnitsWithNames": [
    "[FR] France",
    "[GB] UK",
    "[DE] Germany"
  ],
  "@timestamp": "2020-07-23T04:12:00.376Z"
}

Output should be (concatenate):

"skuNum": " 871123365V",
"businessUnits": "FR,JP,IE,FR,GB,DE"
  "businessUnitsWithNames": [
    "[FR] France",
    "[JP] Japan",
    "[IE] Ireland",
"[FR] France",
    "[GB] UK",
    "[DE] Germany"
  ],

```

Please help me with this use case

---

<div class="post-metadata">

### Author: ![Mangesh\_Mathe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mangesh_mathe/32/103371_2.png) [@Mangesh\_Mathe](https://discuss.elastic.co/u/Mangesh_Mathe)
#### Post date: [February 24, 2023, 6:26am UTC](https://discuss.elastic.co/t/add-any-2-index-to-form-new-index-which-will-combined-data-and-should-not-override-any-fields-values/326173/2 "2023-02-24T06:26:37Z")

</div>

@warkolm @stephenb Can you please help me?  
Thanks in advance!

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [February 24, 2023, 4:01pm UTC](https://discuss.elastic.co/t/add-any-2-index-to-form-new-index-which-will-combined-data-and-should-not-override-any-fields-values/326173/3 "2023-02-24T16:01:19Z")

</div>

Hi @Mangesh_Mathe Please try not to `@` people that are not in your conversation it is not community best practice.

As far as I can tell, neither [reindex](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-multiple-sources) nor [update\_by\_query](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html) will accomplish what you want I think you are going to need to write some custom code to do what you want.

Your use case requires that both documents `_source`s are accessed at the same time so they can be "merged" ... neither reindex nor update\_by\_query have that capability as far as I know.

Perhaps someone else will know how.

But I think you are going to need to write some code that grabs both docs and then merges them to your spec and then writes the new merged doc.

---

<div class="post-metadata">

### Author: ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)
#### Post date: [February 24, 2023, 5:09pm UTC](https://discuss.elastic.co/t/add-any-2-index-to-form-new-index-which-will-combined-data-and-should-not-override-any-fields-values/326173/4 "2023-02-24T17:09:46Z")

</div>

how many document do you have in them, 100 - 1000 or millions?  
do they have uniq key "skuNum" ?

---

<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: [March 24, 2023, 5:10pm UTC](https://discuss.elastic.co/t/add-any-2-index-to-form-new-index-which-will-combined-data-and-should-not-override-any-fields-values/326173/5 "2023-03-24T17:10:33Z")

</div>

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