I cannot create a dynamic mapping

Hello everyone,

I am trying to create two index templates via the UI - one of them has a dynamic mapping that would keep only text fields for all strings from an event, and one that would keep only keyword fields.

I was able to create the keyword one, using this dynamic mapping:

[
  {
    "strings": {
      "mapping": {
        "ignore_above": 256,
        "type": "keyword"
      },
      "match_mapping_type": "string"
    }
  }
]

However, if I try to change it to

[
  {
    "strings": {
      "mapping": {
        "ignore_above": 256,
        "type": "text"
      },
      "match_mapping_type": "string"
    }
  }
]

I receive the following error:

Unable to create template
composable template [custom-text-only] template after composition is invalid

Can you please explain what the issue might be?

The text type usually requires an analyzer property, which is often necessary to define how the text should be analyzed and indexed.

you should include an analyzer in your dynamic template for text fields.

 [
        {
          "strings": {
            "mapping": {
              "type": "text",
              "analyzer": "standard"
            },
            "match_mapping_type": "string"
          }
        }
]

1 Like

Welcome!

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

Have a look at the Elastic Stack and Solutions Help · Forums and Slack | Elastic page. It contains also lot of useful information on how to ask for help.

Here we don't see the exact steps and the API you are calling.
Thanks