Dynamic Templates on Documents with Inner Objects

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:

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"
  }
}
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

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