# Copy index fields from one ES to another

**URL:** <https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954>\
**Category:** Elasticsearch\
**Created:** [March 31, 2020, 10:44pm UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954 "2020-03-31T22:44:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyberzlo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyberzlo/32/65490_2.png) [@cyberzlo](https://discuss.elastic.co/u/cyberzlo)\
**Post date:** [March 31, 2020, 10:44pm UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/1 "2020-03-31T22:44:54Z")

</div>

How can I download index "Fields" frome one ES and upload it to another?

I would like not to direct copy between instances, but store it as some config to use in many ES which don't have connection between another instances.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 1, 2020, 12:38am UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/2 "2020-04-01T00:38:42Z")

</div>

Just to be clear, you don't want the data, just the mapping?

---

<div class="post-metadata">

**Author:** ![cyberzlo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyberzlo/32/65490_2.png) [@cyberzlo](https://discuss.elastic.co/u/cyberzlo)\
**Post date:** [April 1, 2020, 12:49am UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/3 "2020-04-01T00:49:40Z")

</div>

Yes, exactly 🙂

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 1, 2020, 12:51am UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/4 "2020-04-01T00:51:46Z")

</div>

The look at the [`_mapping`](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) API endpoint 🙂

---

<div class="post-metadata">

**Author:** ![cyberzlo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyberzlo/32/65490_2.png) [@cyberzlo](https://discuss.elastic.co/u/cyberzlo)\
**Post date:** [April 1, 2020, 1:07am UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/5 "2020-04-01T01:07:26Z")

</div>

Can you please share little more details? To be honest I am every new in ELK Stack. Not sure how do this, if I need/can do only curl query to download and upload? If yes, can you give me please example of such curl commands to download and upload? Thanks!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 1, 2020, 4:04am UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/6 "2020-04-01T04:04:24Z")

</div>

No worries!

You will want to run `curl -XGET ESHOST:9200/INDEXNAME/_mapping`, replace `ESHOST` with one of the nodes and `INDEXNAME` with the index you want the mapping of.

If you need to use a username and password, then add `-u username:password` before the `-XGET`.

---

<div class="post-metadata">

**Author:** ![cyberzlo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyberzlo/32/65490_2.png) [@cyberzlo](https://discuss.elastic.co/u/cyberzlo)\
**Post date:** [April 1, 2020, 2:15pm UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/7 "2020-04-01T14:15:39Z")

</div>

Thanks, I will sounds lame but my index have asterix ("test-\*")... so I guess i can't just use name and this is reason why I got 404. I am using correct address/port. I tried use ID from URL which I got when loading this fields list but looks like this is not how it can works.

Additional question, how load/push later this mapping to another ES with curl?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 1, 2020, 10:02pm UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/8 "2020-04-01T22:02:08Z")

</div>

Can you post the command you ran and the full output?

Please also remember to format your code/logs/config using the `</>` button, or markdown style back ticks. It helps to make things easy to read which helps us help you 🙂

---

<div class="post-metadata">

**Author:** ![cyberzlo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyberzlo/32/65490_2.png) [@cyberzlo](https://discuss.elastic.co/u/cyberzlo)\
**Post date:** [April 2, 2020, 10:04am UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/9 "2020-04-02T10:04:11Z")

</div>

Actually it started working with \*, not sure, maybe made some mistake last time, thanks!

How can I upload this json as 'index pattern' (test-\* because my indexes have names for each day like test-2020-04-02 etc) to another elasticsearch?

Accually due export it making also indexes per day, but will it work as index patern for all, incuding future indexes? also is this good to make indexes per day or should I have one general?

I am using it for selected network protocols and currently I have 920 fields (from 1000 afair). BTW, should I refresh this fields in index pattern menu from time to time? It change something (like elastic work faster due analysis of it etc) or this is just about load this list of fields to just show me all fields from indexes which match pattern?

I guess I can 'exclude' some fields from indexing in patterns etc. Will it speed up something or it don't change anything in matter that make it sense to bother about that number of fields?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 2, 2020, 9:01pm UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/10 "2020-04-02T21:01:43Z")

</div>

Try `curl -XPUT ESHOST:9200/NEWINDEXNAME -d @mappingfile.json`

Check out [the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) too, it has practical examples using Kibana Dev Tools, or you can copy them as curl commands 🙂

If you want the mapping to apply to more than one index, then take a look at [index templates](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/indices-templates.html),

You don't need to refresh the index mapping in Kibana settings unless you make a mapping change in Elasticsearch.

Excluding fields can improve performance, but if it's only a few then it may not be worth it.

---

<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:** [April 30, 2020, 9:01pm UTC](https://discuss.elastic.co/t/copy-index-fields-from-one-es-to-another/225954/11 "2020-04-30T21:01:47Z")

</div>

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