# How to copy only mapping not data

**URL:** <https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415>\
**Category:** Elasticsearch\
**Tags:** reindex\
**Created:** [June 6, 2022, 12:09am UTC](https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415 "2022-06-06T00:09:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sameer\_khamkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sameer_khamkar/32/104910_2.png) [@sameer\_khamkar](https://discuss.elastic.co/u/sameer_khamkar)\
**Post date:** [June 6, 2022, 12:09am UTC](https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415/1 "2022-06-06T00:09:28Z")

</div>

Hello There,

I am new to ES, and I want to know if we have any way to copy only mappings not data,

Or any way to create new index with old mappings, without data

Regards,  
Sam

---

<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:** [June 6, 2022, 1:40am UTC](https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415/2 "2022-06-06T01:40:23Z")

</div>

`GET indexname/_mapping` will provide that, then you can copy, paste and then post it to the new index

---

<div class="post-metadata">

**Author:** ![sameer\_khamkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sameer_khamkar/32/104910_2.png) [@sameer\_khamkar](https://discuss.elastic.co/u/sameer_khamkar)\
**Post date:** [June 6, 2022, 5:41am UTC](https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415/3 "2022-06-06T05:41:45Z")

</div>

@warkolm

you mean to say follow below

`curl -GET http://localhost:9200/old_index/_mapping?pretty -o old_index.json`

`curl -X PUT http://localhost:9200/holly_good -H 'Content-Type: application/json' -d @old_index.json`

but it gives error

` {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"analyzer [analyzer_keyword] not found for field [source]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [message]: analyzer [analyzer_keyword] not found for field [source]","caused_by":{"type":"mapper_parsing_exception","reason":"analyzer [analyzer_keyword] not found for field [source]"}},"status":400}`

and I am not aware where to define analyzer , I am new to ES can you guide here.

Regards,  
SAM

---

<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:** [June 6, 2022, 6:23am UTC](https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415/4 "2022-06-06T06:23:55Z")

</div>

Share your `old_index.json`

What version ES? Same old and new?

---

<div class="post-metadata">

**Author:** ![sameer\_khamkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sameer_khamkar/32/104910_2.png) [@sameer\_khamkar](https://discuss.elastic.co/u/sameer_khamkar)\
**Post date:** [June 6, 2022, 9:08am UTC](https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415/5 "2022-06-06T09:08:13Z")

</div>

ES VERSION 6.8.21 new  
ES VERSION 5.6.5 old

oldindex.json

```auto
{
    "mappings" : {
      "message" : {
        "dynamic_templates" : [
          {
            "internal_fields" : {
              "match" : "gl2_*",
              "match_mapping_type" : "string",
              "mapping" : {
                "type" : "keyword"
              }
            }
          },
          {
            "store_generic" : {
              "match_mapping_type" : "string",
              "mapping" : {
                "type" : "keyword"
              }
            }
          }
        ],
        "properties" : {
          "LoggerName" : {
            "type" : "keyword"
          },
          "MessageParam0" : {
            "type" : "keyword"
          },
          "MessageParam1" : {
            "type" : "long"
          },
          "MessageParam2" : {
            "type" : "keyword"
          },
          "MessageParam3" : {
            "type" : "keyword"
          },
          "MessageParam4" : {
            "type" : "keyword"
          },
          "MessageParam5" : {
            "type" : "keyword"
          },
          "MessageParam6" : {
            "type" : "keyword"
          },
          "MessageParam7" : {
            "type" : "keyword"
          },
          "MessageParam8" : {
            "type" : "keyword"
          },
          "Severity" : {
            "type" : "keyword"
          },
          "SourceClassName" : {
            "type" : "keyword"
          },
          "SourceMethodName" : {
            "type" : "keyword"
          },
          "SourceSimpleClassName" : {
            "type" : "keyword"
          },
          "StackTrace" : {
            "type" : "keyword"
          },
          "Thread" : {
            "type" : "keyword"
          },
          "Time" : {
            "type" : "keyword"
          },
          "facility" : {
            "type" : "keyword"
          },
          "full_message" : {
            "type" : "text",
            "analyzer" : "standard"
          },
          "gl2_accounted_message_size" : {
            "type" : "long"
          },
          "gl2_message_id" : {
            "type" : "keyword"
          },
          "gl2_processing_timestamp" : {
            "type" : "date",
            "format" : "yyyy-MM-dd HH:mm:ss.SSS"
          },
          "gl2_receive_timestamp" : {
            "type" : "date",
            "format" : "yyyy-MM-dd HH:mm:ss.SSS"
          },
          "gl2_remote_ip" : {
            "type" : "keyword"
          },
          "gl2_remote_port" : {
            "type" : "long"
          },
          "gl2_source_input" : {
            "type" : "keyword"
          },
          "gl2_source_node" : {
            "type" : "keyword"
          },
          "level" : {
            "type" : "long"
          },
          "message" : {
            "type" : "text",
            "analyzer" : "standard"
          },
          "source" : {
            "type" : "text",
            "analyzer" : "analyzer_keyword",
            "fielddata" : true
          },
          "streams" : {
            "type" : "keyword"
          },
          "timestamp" : {
            "type" : "date",
            "format" : "yyyy-MM-dd HH:mm:ss.SSS"
          }
        }
      }
    }
  }
}

```

---

<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:** [June 6, 2022, 9:26am UTC](https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415/6 "2022-06-06T09:26:56Z")

</div>

It looks like you are asking about the same error here - [Error":{"root\_cause":[{"type":"mapper\_parsing\_exception","reason":"analyzer [analyzer\_keyword] not found for field](https://discuss.elastic.co/t/error-root-cause-type-mapper-parsing-exception-reason-analyzer-analyzer-keyword-not-found-for-field/306416) - so let's just keep this one about your original question in this topic

---

<div class="post-metadata">

**Author:** ![sameer\_khamkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sameer_khamkar/32/104910_2.png) [@sameer\_khamkar](https://discuss.elastic.co/u/sameer_khamkar)\
**Post date:** [June 6, 2022, 9:55am UTC](https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415/7 "2022-06-06T09:55:25Z")

</div>

@warkolm@stephenb -  
I am sorry I didn't noticed that , since I am new to ES that forced me to ask questions desperately everywhere.

Please guide if possible.

Regards,  
SAM

---

<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 4, 2022, 9:56am UTC](https://discuss.elastic.co/t/how-to-copy-only-mapping-not-data/306415/8 "2022-07-04T09:56:17Z")

</div>

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