How to copy only mapping not data

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

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

1 Like

@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

Share your old_index.json

What version ES? Same old and new?

ES VERSION 6.8.21 new
ES VERSION 5.6.5 old

oldindex.json

{
    "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"
          }
        }
      }
    }
  }
}

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 - so let's just keep this one about your original question in this topic

@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