{"record":{"id":"3c0a10f2c8582d69","repo":"prestodb/presto","slug":"elasticsearch-type-mismatch-3c0a10","errorCode":"ELASTICSEARCH_TYPE_MISMATCH","errorMessage":"Expected a numeric value for field %s of type DOUBLE: %s [%s]","messagePattern":"Expected a numeric value for field (.+?) of type DOUBLE: (.+?) \\[(.+?)\\]","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/decoders/DoubleDecoder.java","lineNumber":48,"sourceCode":"    private final String path;\n\n    public DoubleDecoder(String path)\n    {\n        this.path = requireNonNull(path, \"path is null\");\n    }\n\n    @Override\n    public void decode(Hit hit, Supplier<Object> getter, BlockBuilder output)\n    {\n        Object value = getter.get();\n        if (value == null) {\n            output.appendNull();\n        }\n        else if (value instanceof Number) {\n            DOUBLE.writeDouble(output, ((Number) value).doubleValue());\n        }\n        else {\n            throw new PrestoException(ELASTICSEARCH_TYPE_MISMATCH, format(\"Expected a numeric value for field %s of type DOUBLE: %s [%s]\", path, value, value.getClass().getSimpleName()));\n        }\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":52,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/decoders/DoubleDecoder.java#L30-L52","documentation":"DoubleDecoder decodes a field declared as DOUBLE. Null decodes to NULL and a Number is written as a double; any other value (string, boolean, object) throws PrestoException(ELASTICSEARCH_TYPE_MISMATCH) since the value cannot be converted to a floating-point number.","triggerScenarios":"A document stores a non-numeric value (e.g. \"price\": \"9.99\" as a string, or \"price\": \"N/A\") in a field declared DOUBLE; thrown during scan-time decoding.","commonSituations":"Ingestion pipeline writes numeric fields as strings; sentinel values like \"N/A\" or \"\" in data originally exported from spreadsheets; ES mapping drift between float/double and keyword/text across documents or indices under one alias.","solutions":["Fix/reindex the documents so the field holds numeric JSON values.","Declare the column as VARCHAR in Presto and cast (CAST(price AS DOUBLE)) in queries if strings are intentional.","Add an ES ingest pipeline with a convert processor (string -> double) to normalize on write.","Align mappings across all indices covered by the queried alias/pattern."],"exampleFix":"// before (document)\n{ \"price\": \"9.99\" }\n// after\n{ \"price\": 9.99 }","handlingStrategy":"validation","validationCode":"// find documents whose double field is a string\ncurl -s 'localhost:9200/<index>/_search' -H 'Content-Type: application/json' -d '{\n  \"query\": { \"bool\": { \"filter\": { \"script\": { \"script\": {\n    \"source\": \"doc[\\\"price\\\"].size()!=0 && !(doc[\\\"price\\\"].value instanceof Number)\"\n  } } } } } }'","typeGuard":null,"tryCatchPattern":"try {\n    rs = stmt.executeQuery(\"SELECT price FROM es.default.idx\");\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"ELASTICSEARCH_TYPE_MISMATCH\")) {\n        // reindex with convert processor: string -> double for price\n    } else { throw e; }\n}","preventionTips":["Emit numeric JSON values (unquoted) for double columns in ingestion.","Use an ES ingest pipeline convert processor for string-heavy sources (CSV, spreadsheets).","Replace sentinel strings like \"N/A\" with null before indexing.","Keep the Presto DOUBLE column in sync with the ES numeric mapping."],"tags":["elasticsearch","type-mismatch","decoder","double","data-quality"],"backgroundTag":"type-mismatch-decoding","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}