# Set data type for object in template

**URL:** <https://discuss.elastic.co/t/set-data-type-for-object-in-template/146461>\
**Category:** Elasticsearch\
**Created:** [August 29, 2018, 4:35am UTC](https://discuss.elastic.co/t/set-data-type-for-object-in-template/146461 "2018-08-29T04:35:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![insomniac](https://avatars.discourse-cdn.com/v4/letter/i/bb73d2/32.png) [@insomniac](https://discuss.elastic.co/u/insomniac)\
**Post date:** [August 29, 2018, 4:35am UTC](https://discuss.elastic.co/t/set-data-type-for-object-in-template/146461/1 "2018-08-29T04:35:25Z")

</div>

I have a template created so that one of the fields is recognised as an integer/long type instead of a string, however it doesn't take effect.

Here's the template I have set up:

```
"templatename": {
  "mappings": {
    "doc": {
      "properties": {
        "event_data": {
           "type": "object",
           "properties": {
             "CSEElaspedTimeInMilliSeconds": {
             "type": "long"
             }
           }
         }
       }
     }
  }
}

```

And here's the raw object looks like this:

```
{
  "_type": "doc",
  "_source": {
    "event_data": {
      "ErrorCode": "0",
      "CSEExtensionName": "Registry",
      "CSEExtensionId": "{35378EAC-683F-11D2-A89A-00C04FBBCFA2}",
      "CSEElaspedTimeInMilliSeconds": "905"
    }
 }
}

```

However the field is still being presented as a text field, even after creating a new index.  
Anyone able to point me in the right direction?

Edit:  
There was nothing wrong with the template - I just had to refresh the field list for the index patterns!

---

<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:** [September 26, 2018, 4:35am UTC](https://discuss.elastic.co/t/set-data-type-for-object-in-template/146461/2 "2018-09-26T04:35:26Z")

</div>

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