# Defining dynamic types in field.yml

**URL:** https://discuss.elastic.co/t/defining-dynamic-types-in-field-yml/149173
**Category:** Beats
**Tags:** beats-development
**Created:** [September 19, 2018, 6:07pm UTC](https://discuss.elastic.co/t/defining-dynamic-types-in-field-yml/149173 "2018-09-19T18:07:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sentient](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sentient/32/34996_2.png) [@sentient](https://discuss.elastic.co/u/sentient)
#### Post date: [September 19, 2018, 6:07pm UTC](https://discuss.elastic.co/t/defining-dynamic-types-in-field-yml/149173/1 "2018-09-19T18:07:04Z")

</div>

I'm struggling a bit to define dynamic types in field.yml for my Statsdbeat

There are some fields that are predefined. But some some fields are dynamic.

My fields.yml is defined as

```auto
- key: statsdbeat
  title: statsdbeat
  description: test
  fields:
    - name: statsd
      type: group
      fields:        
        - name: bucket
          type: text
          ignore_above: 1024        
          description: >
            statsd bucket
        
        - name: val
          type: long          
          description: >
            value for the bucket
        
        - name: type
          type: keyword
          ignore_above: 255        
          description: >
            The type of statsd counter gauge histogram.
        
        - name: context
          type: object
          object_type: keyword
          dynamic: true
          description: >
            Contains user tags

```

When I look in Elastic search on the submitted index template I see

```auto
> GET _template/statsdbeat*

{
  "statsdbeat-6.3.3": {
    "order": 1,
    "index_patterns": [
      "statsdbeat-6.3.3-*"
    ],
    "mappings": {
      "doc": {
        "_meta": {
          "version": "6.3.3"
        },
        "date_detection": false,
        "dynamic_templates": [
          ...<deleted>...
          {
            "statsd.context": {
              "path_match": "statsd.context.*",
              "mapping": {
                "type": "keyword"
              },
              "match_mapping_type": "string"
            }
          },
          {
            "strings_as_keyword": {
              "mapping": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "match_mapping_type": "string"
            }
          }
        ],

```

This seems to be correct (?).  
But when I submit a value for

"statsd.context.userField": "customValue"

The "statsd.context.userField" shows "No cached mapping"

I was expecting that new fields of type string would be mapped to keywords.

---

<div class="post-metadata">

### Author: ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)
#### Post date: [September 22, 2018, 2:06pm UTC](https://discuss.elastic.co/t/defining-dynamic-types-in-field-yml/149173/2 "2018-09-22T14:06:19Z")

</div>

Hi @sentient,

Configuration and mapping look good, yes. Where are you seeing the "No cached mapping" message? If it is in kibana you may need to refresh the field list from the Index patterns management view.

---

<div class="post-metadata">

### Author: ![sentient](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sentient/32/34996_2.png) [@sentient](https://discuss.elastic.co/u/sentient)
#### Post date: [September 25, 2018, 3:45pm UTC](https://discuss.elastic.co/t/defining-dynamic-types-in-field-yml/149173/3 "2018-09-25T15:45:57Z")

</div>

It was indeed just the UI of Kibana that threw me off.

all good

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 23, 2018, 3:50pm UTC](https://discuss.elastic.co/t/defining-dynamic-types-in-field-yml/149173/4 "2018-10-23T15:50:43Z")

</div>

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