# How to map a field inside an object in elastic search

**URL:** https://discuss.elastic.co/t/how-to-map-a-field-inside-an-object-in-elastic-search/191816
**Category:** Elasticsearch
**Created:** [July 23, 2019, 12:57pm UTC](https://discuss.elastic.co/t/how-to-map-a-field-inside-an-object-in-elastic-search/191816 "2019-07-23T12:57:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rahulkothanath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahulkothanath/32/99122_2.png) [@rahulkothanath](https://discuss.elastic.co/u/rahulkothanath)
#### Post date: [July 23, 2019, 12:57pm UTC](https://discuss.elastic.co/t/how-to-map-a-field-inside-an-object-in-elastic-search/191816/1 "2019-07-23T12:57:56Z")

</div>

I have a template mapping like below.

```
  {
    	"order": 0,
    	"index_patterns": [
    		"*xyz_foundation*"
    	],
    	"settings": {
    		"index": {
    			"number_of_shards": "6",
    			"number_of_replicas": "1"
    		},
    		"index.mapping.ignore_malformed": true
    	},
    	"mappings": {
    		"_doc": {
    			"dynamic_templates": [{
    					"imx_integer": {
    						"path_match": "imx.imResponse.policy_score*",
    						"match_mapping_type": "string",
    						"mapping": {
    							"type": "float"
    						}
    					},
				        {
            "string_fields": {
              "match": "*",
              "match_mapping_type": "string",
              "mapping": {
                "type": "keyword"
              }
            }
          }
    				}
              ],
    			"properties": {
    				"xyz": {
    					"properties": {
    					"VER_NO": {
     							"type": "keyword"

     						}
    					}
    				},
    				"imx": {
                          "type": "object"
    				}
                   }
    		}
    	},
    	"aliases": {
    		"xyz_foundation": {}
}}

```

the imx object can contain objects and n number of fields , so I broadly defined it as object and defined match string as keyword in dynamic template.

now I have a new field called "imx.imResponse.policy\_score" which must be considered as float. I defined the mapping inside dynamic template section as in above template.  
how can I define mapping for "imx.imResponse.policy\_score" as float in a better way..? can I define it inside imx object..?

thanks for reading and helping.

---

<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: [August 20, 2019, 12:58pm UTC](https://discuss.elastic.co/t/how-to-map-a-field-inside-an-object-in-elastic-search/191816/2 "2019-08-20T12:58:01Z")

</div>

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