Error create index template in ES 6.7

I created index template in ES 6.7 and got error .

{
  "mappings" : {
    "date_detection": false,
    "dynamic_templates": [
      {
        "labels": {
          "mapping": {
            "type": "keyword"
          },
          "match_mapping_type": "string",
          "path_match": "labels.*"
        }
      },
      {
        "fields": {
          "mapping": {
            "type": "keyword"
          },
          "match_mapping_type": "string",
          "path_match": "fields.*"
        }
      },
      {
        "data.nonTerminatingMatchingRules": {
          "mapping": {
            "type": "keyword"
          },
          "match_mapping_type": "string",
          "path_match": "data.nonTerminatingMatchingRules.*"
        }
      }
    ],
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "data" : {
        "properties" : {
          "nonTerminatingMatchingRules" : {
            "properties" : {
              "action" : {
                "ignore_above" : 1024,
                "type" : "keyword"
              },
              "ruleId" : {
                "ignore_above" : 1024,
                "type" : "keyword"
              }
            }
          }
        }
      }
    }
  }
  "settings": {
    "index.refresh_interval": "5s",
    "number_of_shards" : "1"
  },
  "index_patterns": ["cwl--aws-lambda*"],
  "template": "cwl--aws-lambda*"
}

And error

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Malformed [mappings] section for type [dynamic_templates], should include an inner object describing the mapping"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Malformed [mappings] section for type [dynamic_templates], should include an inner object describing the mapping"
  },
  "status": 400
}

the data above is not valid JSON, so it's very likely not the JSON, which triggered this exception. Please provide the exact call you executed (including HTTP verb and path) in order to be able to reproduce.

Also, please specify the exact elasticsearch version.

Thank you!

Thank @spinscale Sorry about that, i edited json file.

And im using ES 6.7 and use Dev Tools in kibana to create index template

PUT _template/aws-lambda
{
  "mappings" : {
    "date_detection": false,
    "dynamic_templates": [
      {
        "data.nonTerminatingMatchingRules": {
          "mapping": {
            "type": "keyword"
          },
          "match_mapping_type": "string",
          "path_match": "data.nonTerminatingMatchingRules.*"
        }
      }
    ],
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "data" : {
        "properties" : {
          "nonTerminatingMatchingRules" : {
            "properties" : {
              "action" : {
                "ignore_above" : 1024,
                "type" : "keyword"
              },
              "ruleId" : {
                "ignore_above" : 1024,
                "type" : "keyword"
              }
            }
          }
        }
      }
    }
  },
  "settings": {
    "index.refresh_interval": "5s",
    "number_of_shards" : "1"
  },
  "index_patterns": ["cwl--aws-lambda*"],
  "template": "cwl--aws-lambda*"
}

you need to specify a type for which this mapping should apply - it seems you took this example from the Elasticsearch 7 documentation.

You can either add a mapping type or use a parameter like this

PUT _template/aws-lambda?include_type_name=false

See https://www.elastic.co/guide/en/elasticsearch/reference/6.8/removal-of-types.html#_what_are_mapping_types

1 Like

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