# Strange behavior on inserting/reindexing float and int

**URL:** https://discuss.elastic.co/t/strange-behavior-on-inserting-reindexing-float-and-int/160941
**Category:** Elasticsearch
**Created:** [December 14, 2018, 4:40pm UTC](https://discuss.elastic.co/t/strange-behavior-on-inserting-reindexing-float-and-int/160941 "2018-12-14T16:40:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pdesgarets](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pdesgarets](https://discuss.elastic.co/u/pdesgarets)
#### Post date: [December 14, 2018, 4:40pm UTC](https://discuss.elastic.co/t/strange-behavior-on-inserting-reindexing-float-and-int/160941/1 "2018-12-14T16:40:46Z")

</div>

Hi,

I'm observing a strange behavior regarding mapping. I use dynamic mapping. I insert both int and floats.

First observation : Why does Elasticsearch allow those insertions ? Shouldn't it forbid it if the dynamic mapping is "long" and I try to insert a float ?

After those insertions, I want to do a reindex. And it fails ONCE with "mapper [my\_field] cannot be changed from type [long] to [float]" or "mapper [my\_field] cannot be changed from type [float] to [long]". It does succeed on the second attempt (if I use `"conflicts": "proceed"`).  
Shouldn't it succeed every time, or fail every time ?  
And what is the best solution to make the reindex work on the first attempt ? (with the hypothesis "Can't use static mapping") Use `match_mapping_type` to store `long` as `float` ?

Reproducible code for Kibana console follows :

```auto
# Cleaning
# DELETE mynewindex
# DELETE mynewindex_2

PUT mynewindex

# First insert an int. Mapping is then `long` for "my_field"
POST mynewindex/_doc/1
{
  "my_field": 1
}

GET mynewindex/_doc/1

# float insertion succeeds ?!
POST mynewindex/_doc/2
{
  "my_field": 1.5
}

GET mynewindex/_doc/2

GET mynewindex/_mapping

# following request fails on the first time, succeeds on the second time
POST _reindex?wait_for_completion=true
{
  "source": {
    "index": "mynewindex"
  },
  "dest": {
    "index": "mynewindex_2",
    "op_type": "create"
  },
  "conflicts": "proceed"
}

GET mynewindex_2/_mapping
GET mynewindex_2/_doc/1
GET mynewindex_2/_doc/2 

```

Thanks

---

<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: [January 11, 2019, 4:40pm UTC](https://discuss.elastic.co/t/strange-behavior-on-inserting-reindexing-float-and-int/160941/2 "2019-01-11T16:40:58Z")

</div>

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