I am trying to add ingore_malformed to true on an existing field in elasticsearch 6.7 and see mapping type is missing error, How to handle this?

PUT/<index pattern>/_mapping
{
  "properties": {
    "max_size":{
      "type":"long", 
      "ignore_malformed": true
    }
  }
}

Response be like 


  "error": {
    "root_cause": [
      {
        "type": "action_request_validation_exception",
        "reason": "Validation Failed: 1: mapping type is missing;"
      }
    ],
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: mapping type is missing;"
  },
  "status": 400
}

Are you on Elasticsearch 6.x or 7.x?

There is a difference between those versions. You have to specify the type in the API request.
See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#indices-put-mapping vs
https://www.elastic.co/guide/en/elasticsearch/reference/6.5/indices-put-mapping.html#indices-put-mapping

E.g.

PUT <index pattern>/_mapping/_doc 
{ ...

Replace _doc by the type name you're using.

As mentioned in the description we are on 6.7 means 6.x

What do you mean by type name?

I have copied my actual response in the question. So what will be the type name in my case>

Do:

PUT/<index pattern>/_mapping
{
  "properties": {
    "_doc":
    "max_size":{
      "type":"long", 
      "ignore_malformed": true
    }
  }}
}
1 Like

Any of the following work:

PUT /<index pattern>/_mapping/_doc
{
  "properties": {
    "max_size":{
      "type":"long", 
      "ignore_malformed": true
    }
  }
}
PUT /<index pattern>/_mapping?include_type_name=false
{
  "properties": {
    "max_size":{
      "type":"long", 
      "ignore_malformed": true
    }
  }
}

Replace _doc by the type name you're using.

If you don't know the type you're using, get it using GET <index pattern>/_mapping?include_type_name=true.

E.g.

{
  "<index name>" : {
    "mappings" : {
      "_doc" : {  <<<< THIS ONE
        "properties" : {
          "max_size" : {
            "type" : "long",
            "ignore_malformed" : true
          }
        }
      }
    }
  }
}

1 Like

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