Strange behavior on inserting/reindexing float and int

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 :

# 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

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