Kibana: [Mappings editor] Accommodate legacy index templates with multiple mappings types

Created on 13 Jan 2020  路  4Comments  路  Source: elastic/kibana

Per discussion with @romseygeek, 5.x index templates can be created with multiple types, and these index templates would be preserved via the 5.x->6 and 6.x->7 rolling upgrade process. This means we can expect situations in which the mappings editor attempts to consume index templates shaped like this:

PUT _template/template_1
{
  "template": "te*",
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "type1": {
      "properties": {
        "name1": {
          "type": "keyword"
        }
      }
    },
    "type2": {
      "properties": {
        "name2": {
          "type": "keyword"
        }
      }
    }
  }
}

In such a scenario, I suggest we hide the tree and show a warning to the user that multiple types have been detected and that we only support a single type. We can link to the types removal docs, which provides guidance on this change.

If a JSON editor is available, then we can render that.

NOTE: When implementing the logic for detecting multiple types, we should count the properties enumerated on the mappings object. We can't simply look for mappings.properties and assume only one type is defined, because they may have named one of their types properties and have other types defined.

NOTE: It's also possible this change may only need to target 7.x, since ES plans on disallowing this scenario in 8.0.

Mappings Editor Elasticsearch UI bug

All 4 comments

Pinging @elastic/es-ui (Team:Elasticsearch UI)

I suggest we hide the tree and show a warning to the user that multiple types have been detected and that we only support a single type.

Yes, I think that is the best way to handle the possible coming bug. Putting back the JSON editor would be adding a feature that we don't want to do for 7.6. 馃憤

Sounds great, @sebelga. Alan did some digging and found that there is no easy way to seed a 5.x index template in 7.x or 8.x. He suggested building a temporary mock instead to test our solution.

Can't we simply use the "Load JSON" for that? @cjcenizal (apart from having tests)

[EDIT] No that won't work as we already parse the JSON and clean it up 馃槉

Was this page helpful?
0 / 5 - 0 ratings