# Why integer 1 converted to 1.0 in a string field

**URL:** <https://discuss.elastic.co/t/why-integer-1-converted-to-1-0-in-a-string-field/132360>\
**Category:** Elasticsearch\
**Created:** [May 17, 2018, 2:54pm UTC](https://discuss.elastic.co/t/why-integer-1-converted-to-1-0-in-a-string-field/132360 "2018-05-17T14:54:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mingc](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@mingc](https://discuss.elastic.co/u/mingc)\
**Post date:** [May 17, 2018, 2:54pm UTC](https://discuss.elastic.co/t/why-integer-1-converted-to-1-0-in-a-string-field/132360/1 "2018-05-17T14:54:52Z")

</div>

Hi all,

This is my first post here, if I post at the wrong place, please let me know. Thank you.

I have an index and one of its field is a string type. The field setting looks like below.

GET /myindex/\_mappings  
"myfield": {  
"type": "string",  
"norms": {  
"enabled": false  
},  
"analyzer": "lowercase\_keyword" (my analyzer that combines keyword tokenizer and lowercase tokenizer)  
}

Then my application indexed a document that contains myfield:1

After the document is indexed, if I ran "GET /myindex/\_search?q=(myfield:1)" it says there is no match. But when I ran "GET /myindex/\_search?q=(myfield:1.0)" it can find the document that is just indexed and return the doc to me. When looking at the \_source. \_source does say myfield is 1, not 1.0.

Does anyone know why this happened and how can I fix this to search 1 instead of 1.0?

Thank you

---

<div class="post-metadata">

**Author:** ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)\
**Post date:** [May 25, 2018, 10:29pm UTC](https://discuss.elastic.co/t/why-integer-1-converted-to-1-0-in-a-string-field/132360/2 "2018-05-25T22:29:29Z")

</div>

What ES version are you using, and can you please provide the details of your `"lowercase_keyword"` analyzer. I think the problem could be in it.

The default Standard analyzer used for `string` field is indexing "1" to "1", and your query `"GET /myindex/_search?q=(myfield:1)"` will match.

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [May 25, 2018, 11:36pm UTC](https://discuss.elastic.co/t/why-integer-1-converted-to-1-0-in-a-string-field/132360/3 "2018-05-25T23:36:17Z")

</div>

Json represents all numbers as doubles. So passing it as 1 will be parsed into a double, and then converted to a string when indexing.

---

<div class="post-metadata">

**Author:** ![mingc](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@mingc](https://discuss.elastic.co/u/mingc)\
**Post date:** [May 29, 2018, 3:21pm UTC](https://discuss.elastic.co/t/why-integer-1-converted-to-1-0-in-a-string-field/132360/4 "2018-05-29T15:21:25Z")

</div>

Yes, this is the cause. Thank you.

---

<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:** [June 26, 2018, 3:21pm UTC](https://discuss.elastic.co/t/why-integer-1-converted-to-1-0-in-a-string-field/132360/5 "2018-06-26T15:21:31Z")

</div>

Closed on June 26, 2018, 3:21pm UTC

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