Cannot be changed from type [integer] to [long] when sending index data


We have an existing application which send index data to ElasticSearch. It works properly with ES 7.13. Now I switch the application to OpenSearch 1.1 but encounter below error when sending index data.

“error” : {
“type” : “illegal_argument_exception”,
“reason” : “mapper [fieldConfidence] cannot be changed from type [integer] to [long]”

The fieldConfidence is defined in json like below:


I tested the same json string in OpenSearch Dashboards Dev Tools and got the same error. The fieldConfidence is defined as integer type in index mapping definition. I don’t know why 0 is considered as long type, and even if it is long type, why not OpenSearch try to convert it to integer?

There are more similar errors like below:

cannot be changed from type [float] to [long]"
cannot be changed from type [date] to [long]"
cannot be changed from type [double] to [long]"

We don’t have these issues in Elastic 6 and 7. The latest verified ES version is 7.13. Our application was built by C# and leveraged http client library to send json string to create/update index data. Please suggest if any easy way for the application to work with OpenSearch. Thanks a lot.


Opensearch and Elasticsearch set up the mapping according to the first document you store in your index (unless you specified a mapping prior to any ingestion).
By default, if you PUT a document with “fieldConfidence”:0, it will be created with a long field type.
If you need an integer field type, you can create the mapping first:

PUT test_index

PUT test_index/_mapping
  "properties": {
    "fieldConfidence": {
      "type": "integer"



Thanks for your response. I found this issue was caused by the application logic, which applied different format for ES 6 and ES 7. It didn’t consider the OpenSearch version, so it applied the ES 6 format by mistake, which caused those issues.