# Enforcing mapped types

**URL:** <https://discuss.elastic.co/t/enforcing-mapped-types/5037>\
**Category:** Elasticsearch\
**Created:** [August 2, 2011, 9:06pm UTC](https://discuss.elastic.co/t/enforcing-mapped-types/5037 "2011-08-02T21:06:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rfq\_dev](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rfq\_dev](https://discuss.elastic.co/u/rfq_dev)\
**Post date:** [August 2, 2011, 9:06pm UTC](https://discuss.elastic.co/t/enforcing-mapped-types/5037/1 "2011-08-02T21:06:28Z")

</div>

Quick question: I've created a very simple mapping of a field to be an  
integer. A get of the \_mapping shows the following:  
$ curl -x '' -XGET '[http://localhost:9200/maptest/test/\_mapping?pretty=true](http://localhost:9200/maptest/test/_mapping?pretty=true)'  
{  
"test" : {  
"properties" : {  
"name" : {  
"type" : "string"  
},  
"int\_test" : {  
"store" : "yes",  
"type" : "integer"  
}  
}  
}  
}

However, it doesn't seem that the mapping is being enforced. If I create an  
object with a float or string value, it is accepted, and future GETs have  
the same float or string. i.e.:

$ curl -x '' -XPOST '[http://localhost:9200/maptest/test](http://localhost:9200/maptest/test)' -d '{ "name" :  
"whatever", "int\_test" : 5.22 }'  
{"ok":true,"\_index":"maptest","\_type":"test","\_id":"oO3ShWAlQp693b4b4mW3UQ","\_version":1}

$curl -x '' -XGET  
'[http://localhost:9200/maptest/test/oO3ShWAlQp693b4b4mW3UQ](http://localhost:9200/maptest/test/oO3ShWAlQp693b4b4mW3UQ)'  
{"\_index":"maptest","\_type":"test","\_id":"oO3ShWAlQp693b4b4mW3UQ","\_version":1,"exists":true,  
"\_source" : { "name" : "whatever", "int\_test" : 5.22 }}

$ curl -x '' -XGET  
'[http://localhost:9200/maptest/test/oO3ShWAlQp693b4b4mW3UQ?fields=int\_test](http://localhost:9200/maptest/test/oO3ShWAlQp693b4b4mW3UQ?fields=int_test)'  
{"\_index":"maptest","\_type":"test","\_id":"oO3ShWAlQp693b4b4mW3UQ","\_version":1,"exists":true,"fields":{"int\_test":5.22}}

What am I missing?

Thanks,

- Ruben

--  
View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Enforcing-mapped-types-tp3220227p3220227.html](http://elasticsearch-users.115913.n3.nabble.com/Enforcing-mapped-types-tp3220227p3220227.html)  
Sent from the ElasticSearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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 6, 2017, 3:58am UTC](https://discuss.elastic.co/t/enforcing-mapped-types/5037/2 "2017-07-06T03:58:27Z")

</div>


