# Can I make Elasticsearch store all numbers as doubles in dynamic mapping?

**URL:** https://discuss.elastic.co/t/can-i-make-elasticsearch-store-all-numbers-as-doubles-in-dynamic-mapping/32124
**Category:** Elasticsearch
**Created:** [October 13, 2015, 10:04pm UTC](https://discuss.elastic.co/t/can-i-make-elasticsearch-store-all-numbers-as-doubles-in-dynamic-mapping/32124 "2015-10-13T22:04:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dave](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@dave](https://discuss.elastic.co/u/dave)
#### Post date: [October 13, 2015, 10:04pm UTC](https://discuss.elastic.co/t/can-i-make-elasticsearch-store-all-numbers-as-doubles-in-dynamic-mapping/32124/1 "2015-10-13T22:04:23Z")

</div>

I'm using dynamic mapping to index a bunch of documents with numbers in some fields. Some of these numbers are integers and some have decimal points. If the first point I send to an index happens to have an integer in a field, then Elasticsearch maps that field as a long in that index. So then any subsequent points with decimals in that field get rounded down, and all the math I do on those documents comes out wrong. I don't want this. Can I tell Elasticsearch that I'm not intereseted in longs and only want doubles in my documents?

---

<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: [October 14, 2015, 1:44am UTC](https://discuss.elastic.co/t/can-i-make-elasticsearch-store-all-numbers-as-doubles-in-dynamic-mapping/32124/2 "2015-10-14T01:44:33Z")

</div>

Have you tried creating a static mapping instead?

---

<div class="post-metadata">

### Author: ![dave](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@dave](https://discuss.elastic.co/u/dave)
#### Post date: [October 14, 2015, 1:53am UTC](https://discuss.elastic.co/t/can-i-make-elasticsearch-store-all-numbers-as-doubles-in-dynamic-mapping/32124/3 "2015-10-14T01:53:37Z")

</div>

I don't know what the fields are gonna be in advance, just that some fields will have numbers that might be integers or doubles. So I'm looking at [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#\_dynamic\_templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_dynamic_templates) and thinking that a dynamic template like

```auto
        {
            "long_smasher": {
                "match": "*",
                "match_mapping_type": "long",
                "mapping": {
                    "type": "double"
                }
            }
        },

```

will do the job.

---

<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, 11:44pm UTC](https://discuss.elastic.co/t/can-i-make-elasticsearch-store-all-numbers-as-doubles-in-dynamic-mapping/32124/4 "2017-07-05T23:44:57Z")

</div>


