# Strings coerce to numbers failed

**URL:** <https://discuss.elastic.co/t/strings-coerce-to-numbers-failed/78436>\
**Category:** Elasticsearch\
**Created:** [March 14, 2017, 3:27am UTC](https://discuss.elastic.co/t/strings-coerce-to-numbers-failed/78436 "2017-03-14T03:27:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayqie](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jayqie](https://discuss.elastic.co/u/jayqie)\
**Post date:** [March 14, 2017, 3:27am UTC](https://discuss.elastic.co/t/strings-coerce-to-numbers-failed/78436/1 "2017-03-14T03:27:56Z")

</div>

I enter the code like elasticsearch example, but the coerce result is wrong.

PUT my\_index  
{  
"settings": {  
"index.mapping.coerce": true  
},  
"mappings": {  
"my\_type": {  
"properties": {  
"number\_one": {  
"type": "integer"  
},  
"number\_two": {  
"type": "integer",  
"coerce": false  
}  
}  
}  
}  
}

PUT my\_index/my\_type/1  
{ "number\_one": "10" }

GET my\_index/my\_type/\_search

the result:

{  
"took": 7,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "my\_index",  
"\_type": "my\_type",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"number\_one": "10"  
}  
}  
]  
}  
}

no convertion happened, why?

---

<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:** [April 11, 2017, 3:28am UTC](https://discuss.elastic.co/t/strings-coerce-to-numbers-failed/78436/2 "2017-04-11T03:28:00Z")

</div>

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