Skip to content

dynamic templates are parsed OK but fail during index creation #5199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
faxm0dem opened this issue Feb 20, 2014 · 3 comments
Closed

dynamic templates are parsed OK but fail during index creation #5199

faxm0dem opened this issue Feb 20, 2014 · 3 comments

Comments

@faxm0dem
Copy link

When applying dynamic templates, the following config gets applied OK, but triggers the following error message when ES tries to create the index:

org.elasticsearch.index.mapper.MapperParsingException: A dynamic template must be defined with a name
        "dynamic_templates" : [ {
          "number_fields" : {
            "mapping" : {
              "type" : "float"
            },
            "match_pattern" : "regex",
            "match" : "^(duration|.*_num|.*_dur)$",
            "match_mapping_type" : "string"
          },
          "integer_fields" : {
            "mapping" : {
              "type" : "integer"
            },
            "match_pattern" : "regex",
            "match" : "^(integer|.*_int|.*_len|port|pid|uid|gid|PID|UID|GID|TID|PRI|.*_NUM)$",
            "match_mapping_type" : "string"
          },
          "string_fields" : {
            "mapping" : {
              "type" : "multi_field",
              "fields" : {
                "raw" : {
                  "index" : "not_analyzed",
                  "ignore_above" : 256,
                  "type" : "string"
                },
                "{name}" : {
                  "index" : "analyzed",
                  "omit_norms" : true,
                  "type" : "string"
                }
              }
            },
            "match_mapping_type" : "string",
            "match" : "*"
          }
        } ],

When Only one key exists, e.g. "string_fields", then all is good

@kzwang
Copy link
Contributor

kzwang commented Mar 27, 2014

@faxm0dem the dynamic template should be an array of objects

this is what you got:

{
  "dynamic_templates": [
    {
      "number_fields": {
        "mapping": {
          "type": "float"
        },
        "match_pattern": "regex",
        "match": "^(duration|.*_num|.*_dur)$",
        "match_mapping_type": "string"
      },
      "integer_fields": {
        "mapping": {
          "type": "integer"
        },
        "match_pattern": "regex",
        "match": "^(integer|.*_int|.*_len|port|pid|uid|gid|PID|UID|GID|TID|PRI|.*_NUM)$",
        "match_mapping_type": "string"
      },
      "string_fields": {
        "mapping": {
          "type": "multi_field",
          "fields": {
            "raw": {
              "index": "not_analyzed",
              "ignore_above": 256,
              "type": "string"
            },
            "{name}": {
              "index": "analyzed",
              "omit_norms": true,
              "type": "string"
            }
          }
        },
        "match_mapping_type": "string",
        "match": "*"
      }
    }
  ]
}

and this is the correct one:

{
  "dynamic_templates": [
    {
      "number_fields": {
        "mapping": {
          "type": "float"
        },
        "match_pattern": "regex",
        "match": "^(duration|.*_num|.*_dur)$",
        "match_mapping_type": "string"
      }
    },
    {
      "integer_fields": {
        "mapping": {
          "type": "integer"
        },
        "match_pattern": "regex",
        "match": "^(integer|.*_int|.*_len|port|pid|uid|gid|PID|UID|GID|TID|PRI|.*_NUM)$",
        "match_mapping_type": "string"
      }
    },
    {
      "string_fields": {
        "mapping": {
          "type": "multi_field",
          "fields": {
            "raw": {
              "index": "not_analyzed",
              "ignore_above": 256,
              "type": "string"
            },
            "{name}": {
              "index": "analyzed",
              "omit_norms": true,
              "type": "string"
            }
          }
        },
        "match_mapping_type": "string",
        "match": "*"
      }
    }
  ]
}

@faxm0dem
Copy link
Author

Thanks, I'll try that.
However, I there should be an input validation, what's your opinion on that?

@clintongormley
Copy link
Contributor

Closing in favour of #8802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants