24
votes

When trying to insert the following mapping in Elasticsearch 7

PUT my_index/items/_mapping
{
   "settings":{

   },
   "mappings":{
      "items":{
         "properties":{
            "products":{
               "properties":{
                  "classification":{
                     "type":"text",
                     "fields":{
                        "raw":{
                           "type":"keyword",
                           "ignore_above":256
                        }
                     }
                  },
                  "original_text":{
                     "type":"text",
                     "store":false,
                     "fields":{
                        "raw":{
                           "type":"keyword",
                           "ignore_above":256
                        }
                     }
                  }
               }
            },
            "title":{
               "type":"text",
               "fields":{
                  "raw":{
                     "type":"keyword",
                     "ignore_above":256
                  }
               },
               "analyzer":"autocomplete"
            },
            "image":{
               "properties":{
                  "type":{
                     "type":"text",
                     "fields":{
                        "raw":{
                           "type":"keyword",
                           "ignore_above":256
                        }
                     }
                  },
                  "location":{
                     "type":"text",
                     "store":false,
                     "fields":{
                        "raw":{
                           "type":"keyword",
                           "ignore_above":256
                        }
                     }
                  }
               }
            }
         }
      }
   }
}

I get an error of the form:

{
"error": {
    "root_cause": [
    {
        "type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters:  

What is causing this error?

1
There are some other questions that have been asked that are very similar, but they are all related to specific uses or relate to versions of Elasticsearch before 7.0.0 The goal of this question / answer is to have a single, clean, generalizable answer for Elasticsearch 7 as this will likely be a common problem as people upgrade from previous versions to ES 7Phil B

1 Answers

23
votes

In Elasticsearch 7, mapping types have been deprecated, which is causing the breaking change at the source of this problem.

Announcement by the Elasticsearch team of the deprecation, roadmap, and alternatives.

To fix this, simply remove all references to mapping types ("items" in this example):

PUT my_index/_mapping
{
   "settings":{

   },
   "mappings":{
      "properties":{
         "products":{
            "properties":{
               "classification":{
                  "type":"text",
                  "fields":{
                     "raw":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               },
               "original_text":{
                  "type":"text",
                  "store":false,
                  "fields":{
                     "raw":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               }
            }
         },
         "title":{
            "type":"text",
            "fields":{
               "raw":{
                  "type":"keyword",
                  "ignore_above":256
               }
            },
            "analyzer":"autocomplete"
         },
         "image":{
            "properties":{
               "type":{
                  "type":"text",
                  "fields":{
                     "raw":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               },
               "location":{
                  "type":"text",
                  "store":false,
                  "fields":{
                     "raw":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               }
            }
         }
      }
   }
}