# Mapping of the fields gets change between double/long

**URL:** https://discuss.elastic.co/t/mapping-of-the-fields-gets-change-between-double-long/51350
**Category:** Elasticsearch
**Created:** [May 30, 2016, 9:54pm UTC](https://discuss.elastic.co/t/mapping-of-the-fields-gets-change-between-double-long/51350 "2016-05-30T21:54:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![bbhandari0121](https://avatars.discourse-cdn.com/v4/letter/b/f0a364/32.png) [@bbhandari0121](https://discuss.elastic.co/u/bbhandari0121)
#### Post date: [May 30, 2016, 9:54pm UTC](https://discuss.elastic.co/t/mapping-of-the-fields-gets-change-between-double-long/51350/1 "2016-05-30T21:54:05Z")

</div>

Hi all,  
I have a logstash config, which creates the new index every day. They are mapped dynamically. The problem with dynamic mapping is, one of my field named value, gets mapped to double and some time it gets mapped to long. How can i restrict my self, for upcoming indexes to for that particular fileld mapped only to double.

logstash config  
input.conf  
input {  
kafka {  
zk\_connect =\> 'ip:2181'  
topic\_id =\> 'collectdmetrics'  
consumer\_threads =\> 3  
group\_id =\> "collectd"  
}  
}

output {  
if [type] == 'collectd' {  
elasticsearch {  
hosts =\> ["ip:9200"]  
manage\_template =\> false  
index =\> "collectdmetrics-%{+YYYY.MM.dd}"  
}  
}

curl -XGET [http://localhost:9200/collectdmetrics-2016.05.29/\_mapping](http://localhost:9200/collectdmetrics-2016.05.29/_mapping)  
{  
"collectdmetrics-2016.05.29": {  
"mappings": {  
"collectd": {  
"properties": {  
"@timestamp": {  
"type": "date",  
"format": "strict\_date\_optional\_time||epoch\_millis"  
},  
"@version": {  
"type": "string"  
},  
"MemoryUsed": {  
"type": "double"  
},  
"Thoughput": {  
"type": "double"  
},  
"host": {  
"type": "string"  
},  
"hostname": {  
"type": "string"  
},  
"message": {  
"type": "string"  
},  
"plugin": {  
"type": "string"  
},  
"port": {  
"type": "long"  
},  
"type": {  
"type": "string"  
},  
"type\_instance": {  
"type": "string"  
},  
"value": {  
"type": "double"  
},  
"value1": {  
"type": "double"  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [May 31, 2016, 1:29am UTC](https://discuss.elastic.co/t/mapping-of-the-fields-gets-change-between-double-long/51350/2 "2016-05-31T01:29:00Z")

</div>

Use a template instead - [https://www.elastic.co/guide/en/elasticsearch/reference/2.3/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/indices-templates.html)

---

<div class="post-metadata">

### Author: ![bbhandari0121](https://avatars.discourse-cdn.com/v4/letter/b/f0a364/32.png) [@bbhandari0121](https://discuss.elastic.co/u/bbhandari0121)
#### Post date: [May 31, 2016, 3:09am UTC](https://discuss.elastic.co/t/mapping-of-the-fields-gets-change-between-double-long/51350/3 "2016-05-31T03:09:51Z")

</div>

Thank you for your assistance. Can i use the above mapping as a template ? And how do i name the new template ? like  
curl -XPUT localhost:9200/\_template/logstash -d '{  
"template" : "logstash\*",  
"order" : 1,  
"mappings": {  
"collectd": {  
"properties": {  
"@timestamp": {  
"type": "date",  
"format": "strict\_date\_optional\_time||epoch\_millis"  
},  
"@version": {  
"type": "string"  
},  
"MemoryUsed": {  
"type": "double"  
},  
"Thoughput": {  
"type": "double"  
},  
"host": {  
"type": "string"  
},  
"hostname": {  
"type": "string"  
},  
"message": {  
"type": "string"  
},  
"plugin": {  
"type": "string"  
},  
"port": {  
"type": "long"  
},  
"type": {  
"type": "string"  
},  
"type\_instance": {  
"type": "string"  
},  
"value": {  
"type": "double"  
},  
"value1": {  
"type": "double"  
}  
}  
}  
}

Also, what happens to the other settings if i just use mapping on the template ? will they be dynamic ?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [May 31, 2016, 3:30am UTC](https://discuss.elastic.co/t/mapping-of-the-fields-gets-change-between-double-long/51350/4 "2016-05-31T03:30:41Z")

</div>

Yes, just adapt the mapping like that.  
Non mapped will be treated as dynamic, just the same as mappings.

---

<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: [July 5, 2017, 10:47pm UTC](https://discuss.elastic.co/t/mapping-of-the-fields-gets-change-between-double-long/51350/5 "2017-07-05T22:47:53Z")

</div>


