elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.79k stars 8.19k forks source link

Adding mappings parameters with double quotes makes index template not editable from the Kibana UI #99739

Open Sergi-GC opened 3 years ago

Sergi-GC commented 3 years ago

Kibana version: 7.12.0 / 7.12.1

Elasticsearch version: 7.12.0 / 7.12.1

Server OS version: ESS

Browser version: any

Browser OS version: any

Describe the bug: If an index template (also for legacy or component templates) has any parameter field defined with double quotes under mappings, the template mappings won't be editable from the Kibana UI in Stack Management > Index Management > Templates > Edit template

Error:

Multiple mapping types detected
The mappings for this template uses multiple types, which are not supported. Consider these alternatives to mapping types.

Screen Shot 2021-05-10 at 3 16 42 PM

From the error it looks like the parameters are being read as the mappings' type by the UI.

Steps to reproduce:

  1. Create a template and add a mappings parameter in double quotes like "dynamic": "true" or "date_detection": "false".
    PUT _template/my_template
    {
    "order": 0,
    "index_patterns": [ "test-*" ],
    "settings": {
    "number_of_shards": "2",
    "number_of_replicas": "1"
    },
    "mappings": {
    "dynamic": "true",
    "date_detection": "false",
    "properties": {
      "field1": {
        "properties": {
          "date": {
            "type": "date"
          }
        }
      }
    }
    }
    }
  2. Try to edit the template from the Kibana UI Stack Management > Index Management > Templates > Edit template

Expected behavior: We should be able to edit the mappings Screen Shot 2021-05-10 at 3 29 00 PM

Workarounds:

  1. Parse the mappings without the double quotes

    PUT _template/my_template
    {
    "order": 0,
    "index_patterns": [ "test-*" ],
    "settings": {
    "number_of_shards": "2",
    "number_of_replicas": "1"
    },
    "mappings": {
    "dynamic": true,
    "date_detection": false,
    "properties": {
      "field1": {
        "properties": {
          "date": {
            "type": "date"
          }
        }
      }
    }
    }
    }
  2. Edit the templates mappings from Kibana Dev Tools.

elasticmachine commented 3 years ago

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

cjcenizal commented 3 years ago

Possibly related to https://github.com/elastic/kibana/issues/107464

alisonelizabeth commented 3 years ago

I did not get a chance to fix this before going on leave, but wanted to share my findings in case anyone else is available to pick this up.

I believe there are two changes that are needed to address this issue:

  1. Update the mappings configuration schema to support string boolean values for dynamic, date_detection, numeric_detection, _source.enabled and _routing.required fields.

    For example:

    dynamic: t.union([t.boolean, t.literal('true'), t.literal('false'), t.literal('strict')]),
  2. Update the configuration form schema to properly deserialize string boolean values to boolean.

elasticmachine commented 3 weeks ago

Pinging @elastic/kibana-management (Team:Kibana Management)