Skip to content

convert ingest processor does not convert float to integer #128160

Open
@efd6

Description

@efd6

Elasticsearch Version

8.18.0

Installed Plugins

No response

Java Version

bundled

OS Version

6.8.0-52-generic #53~22.04.1-Ubuntu

Problem Description

The convert ingest processor does not successfully convert from float to integer types and this absence of capacity is not excluded by the documentation. Either it should be documented that convert is not a general purpose conversion processor or the capacity should be added (preferably the latter).

Steps to Reproduce

POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "convert": {
          "field": "value",
          "target_field": "final",
          "type": "long"
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "value": 9007199254740991
      }
    },
    {
      "_source": {
        "value": 9007199254740991.0
      }
    },
    {
      "_source": {
        "value": "9007199254740991"
      }
    }
  ]
}

gives

{
  "docs": [
    {
      "doc": {
        "_index": "_index",
        "_version": "-3",
        "_id": "_id",
        "_source": {
          "final": 9007199254740992,
          "value": 9007199254740992
        },
        "_ingest": {
          "timestamp": "2025-05-15T06:59:51.39992104Z"
        }
      }
    },
    {
      "error": {
        "root_cause": [
          {
            "type": "illegal_argument_exception",
            "reason": "unable to convert [9.007199254740991E15] to long"
          }
        ],
        "type": "illegal_argument_exception",
        "reason": "unable to convert [9.007199254740991E15] to long",
        "caused_by": {
          "type": "number_format_exception",
          "reason": "For input string: \"9.007199254740991E15\""
        }
      }
    },
    {
      "doc": {
        "_index": "_index",
        "_version": "-3",
        "_id": "_id",
        "_source": {
          "final": 9007199254740991,
          "value": "9007199254740991"
        },
        "_ingest": {
          "timestamp": "2025-05-15T06:59:51.399935971Z"
        }
      }
    }
  ]
}

Logs (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions