# Dynamic Templates on Documents with Inner Objects

**URL:** <https://discuss.elastic.co/t/dynamic-templates-on-documents-with-inner-objects/265821>\
**Category:** Elasticsearch\
**Created:** [March 1, 2021, 2:50pm UTC](https://discuss.elastic.co/t/dynamic-templates-on-documents-with-inner-objects/265821 "2021-03-01T14:50:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eduardo\_Iglesias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eduardo_iglesias/32/78395_2.png) [@Eduardo\_Iglesias](https://discuss.elastic.co/u/Eduardo_Iglesias)\
**Post date:** [March 1, 2021, 2:50pm UTC](https://discuss.elastic.co/t/dynamic-templates-on-documents-with-inner-objects/265821/1 "2021-03-01T14:50:57Z")

</div>

Hello community, I'm trying to apply a dynamic template to my index, even though the console doesn't gives me any error when creating the dynamic template, my documents are still taking the default elasticsearch mappings instead of the ones specified in the dynamic template.

The template works fine when changing the document structure to a single object, I would like to make it work with a inner object structure.

Below are the document structure and the dynamic template that I'm trying to apply:

```auto
POST patient_records/_doc
{
  "patient":{
      "name":"john",
      "middle":"charles",
      "last":"wayne",
      "dob":"01-01-2000",
      "gender":"M",
      "age":"21",
      "weight":"85",
      "height":"1.80"
  },
  "appointment":{
      "date":"02-28-2021",
      "place":"Phoenix",
      "reason":"Montlhy Check"
  }
}

```

```auto
PUT patient_records
{
  "mappings": {
    "dynamic_templates":[
      {
      "strings_to_both_text_keyword":{
        "match_mapping_type":"string",
        "unmatch":["gender","place"],
        "mapping":{"type":"text",
        "fields":{"keyword":{"type":"keyword"}}}}},
      {
        "gender_and_place_keyword_only":{
          "match_mapping_type":"string",
          "mapping":{"type":"keyword"}}},
      {
        "double_to_half_float":{
        "match_mapping_type":"double",
        "mapping":{"type":"scaled_float","scaling_factor":"100"}}},
      {
        "date_to_strict_date_format":{
          "match_mapping_type":"date",
          "mapping":{"type":"date","format":"mm-dd-yyyy"}}}
      ]
  }
}

```

Thanks in advance!  
Eduardo Iglesias

---

<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:** [March 29, 2021, 2:51pm UTC](https://discuss.elastic.co/t/dynamic-templates-on-documents-with-inner-objects/265821/2 "2021-03-29T14:51:40Z")

</div>

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