{"record":{"id":"dd54082bb05d3fb2","repo":"elastic/elasticsearch","slug":"unable-to-convert-to-float","errorCode":null,"errorMessage":"unable to convert [{}] to float","messagePattern":"unable to convert \\[(.+?)\\] to float","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ConvertProcessor.java","lineNumber":78,"sourceCode":"            }\n        },\n        DOUBLE {\n            @Override\n            public Object convert(Object value) {\n                try {\n                    return Double.parseDouble(value.toString());\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"unable to convert [\" + value + \"] to double\", e);\n                }\n            }\n        },\n        FLOAT {\n            @Override\n            public Object convert(Object value) {\n                try {\n                    return Float.parseFloat(value.toString());\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"unable to convert [\" + value + \"] to float\", e);\n                }\n            }\n        },\n        BOOLEAN {\n            @Override\n            public Object convert(Object value) {\n                if (value.toString().equalsIgnoreCase(\"true\")) {\n                    return true;\n                } else if (value.toString().equalsIgnoreCase(\"false\")) {\n                    return false;\n                } else {\n                    throw new IllegalArgumentException(\"[\" + value + \"] is not a boolean value, cannot convert to boolean\");\n                }\n            }\n        },\n        IP {\n            @Override\n            public Object convert(Object value) {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ConvertProcessor.java#L60-L96","documentation":"Thrown by the ConvertProcessor's FLOAT enum constant when Float.parseFloat cannot turn the field's string form into a float. The processor delegates to Float.parseFloat, so any input that is not a parsable IEEE-754 float literal (including locale-specific decimal separators, currency symbols, or text) reaches this NumberFormatException->IllegalArgumentException wrapper. It surfaces during ingest pipeline execution on the document being indexed.","triggerScenarios":"A pipeline with a 'convert' processor whose 'type' is 'float' is applied to a document whose source field value's toString() is non-numeric (e.g. \"N/A\", \"12,5\", \"12.5.0\", empty string). Also triggered for values that overflow Float range.","commonSituations":"Locale-formatted decimals written with a comma instead of a dot; non-numeric sentinel values like '-' or 'null' loaded from CSV/log shippers; schema drift where a previously numeric field starts carrying strings; unit suffixes such as '12.5kg'.","solutions":["Inspect the actual field value in the failing document (the message prints it in brackets) and correct the source data or upstream producer.","Add a script/grok processor before convert to strip non-numeric characters or normalize decimal separators.","Set the convert processor's 'ignore_missing: true' only if absence (not bad values) is the issue; for bad values use an 'on_failure' handler on the pipeline to route the document.","If the value legitimately exceeds float precision, switch the processor 'type' to 'double' instead of 'float'."],"exampleFix":"// before - source field \"price\" = \"12,99\" (comma decimal)\n{\"convert\": {\"field\": \"price\", \"type\": \"float\"}}\n// after - normalize separator first, then convert\n{\"gsub\": {\"field\": \"price\", \"pattern\": \",\", \"replacement\": \".\"}},\n{\"convert\": {\"field\": \"price\", \"type\": \"float\"}}","handlingStrategy":"validation","validationCode":"// In a pipeline, pre-screen the field with a script processor before convert:\n{\"script\": {\"source\": \"if (ctx.price != null && (ctx.price =~ /^-?(?:0x[0-9a-fA-F]+|[0-9]*\\.?[0-9]+(?:[eE][+-]?[0-9]+)?$/).matches() == false) { throw new Exception('bad float: ' + ctx.price) }\"}}","typeGuard":"// painless type guard inside a script processor\nboolean isFloatable(def v) { return v != null && (v instanceof Number || (v.toString() =~ /^-?[0-9]*\\.?[0-9]+$/).matches()); }","tryCatchPattern":"// Configure pipeline on_failure to route convert failures to a DLQ instead of aborting:\n{\"on_failure\": [{\"index\": {\"index\": \"ingest-dlq\"}}], \"processors\": [...]}","preventionTips":["Always pair convert processors with an on_failure handler that writes to a dead-letter index.","For user-provided data, normalize decimal separators and strip units in a prior gsub/script step.","Test pipelines against representative sample documents before applying them to production indices."],"tags":["ingest","convert-processor","type-coercion","data-quality"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}