elastic/elasticsearch · error · IllegalArgumentException
unable to convert [{}] to double
Error message
unable to convert [{}] to double What it means
ConvertProcessor.Type.DOUBLE.convert wraps NumberFormatException from Double.parseDouble on value.toString(). Double.parseDouble is stricter than many users expect: it rejects trailing characters, leading/trailing whitespace, and locale-specific separators. The offending value is interpolated into the message.
Source
Thrown at modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ConvertProcessor.java:68
public Object convert(Object value) {
try {
String strValue = value.toString();
if (strValue.startsWith("0x") || strValue.startsWith("-0x")) {
return Long.decode(strValue);
}
return Long.parseLong(strValue);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("unable to convert [" + value + "] to long", e);
}
}
},
DOUBLE {
@Override
public Object convert(Object value) {
try {
return Double.parseDouble(value.toString());
} catch (NumberFormatException e) {
throw new IllegalArgumentException("unable to convert [" + value + "] to double", e);
}
}
},
FLOAT {
@Override
public Object convert(Object value) {
try {
return Float.parseFloat(value.toString());
} catch (NumberFormatException e) {
throw new IllegalArgumentException("unable to convert [" + value + "] to float", e);
}
}
},
BOOLEAN {
@Override
public Object convert(Object value) {
if (value.toString().equalsIgnoreCase("true")) {
return true;View on GitHub (pinned to db6a809a66)
Solutions
- Strip whitespace, currency symbols, and unit suffixes from the value before convert.
- Replace locale decimal separators (',') with '.' upstream if applicable.
- Set ignore_missing: true for absent fields; filter empty strings upstream.
- Quarantine unparseable values via on_failure.
Example fix
// before — comma decimal separator fails Double.parseDouble
// { "convert": { "field": "temp", "type": "double" } } // temp = "36,6"
//
// after — normalize the separator first
// { "script": { "source": "ctx.temp = ctx.temp.replace(',', '.')" } },
// { "convert": { "field": "temp", "type": "double" } } Defensive patterns
Strategy: validation
Validate before calling
boolean isParsableAsDouble(Object v) {
if (v == null) return false;
String s = v.toString().trim();
try { Double.parseDouble(s); return true; } catch (NumberFormatException ignored) { return false; }
} Type guard
static boolean isDoubleLike(Object v) {
if (v instanceof Number) return true;
if (v instanceof String s) {
try { Double.parseDouble(s.trim()); return true; } catch (NumberFormatException ignored) { return false; }
}
return false;
} Try / catch
{
"convert": {
"field": "temp", "type": "double",
"on_failure": [
{ "set": { "field": "ingest.error", "value": "convert-double" } },
{ "redirect": { "pipeline": "quarantine" } }
]
}
} Prevention
- Double.parseDouble rejects trailing characters — strip units, currency, and whitespace upstream.
- Replace locale decimal separators (',') with '.' before convert.
- Filter empty strings; set ignore_missing: true if the field may be absent.
When it happens
Trigger: convert processor with type: double on a value like '1,5' (comma decimal separator), '12 USD', 'abc', 'NaN-text', or with leading/trailing whitespace. Multi-valued fields fail on the first unparseable element.
Common situations: Non-English locales that use ',' as decimal separator; currency strings; values with units ('3.14m'); values with surrounding whitespace that survived sanitization.
Related errors
- unable to convert [{}] to integer
- unable to convert [{}] to long
- unable to parse URI [${uriString}]
- Illegal escape sequence '\{}'
- Invalid extensions in the CEF event: {}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/35c8e51d970d3530.
Report an issue: GitHub.