{"record":{"id":"48d42f3d4747a9c2","repo":"prestodb/presto","slug":"elasticsearch-type-mismatch-48d42f","errorCode":"ELASTICSEARCH_TYPE_MISMATCH","errorMessage":"Expected a numeric value for field %s of type BIGINT: %s [%s]","messagePattern":"Expected a numeric value for field (.+?) of type BIGINT: (.+?) \\[(.+?)\\]","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/decoders/BigintDecoder.java","lineNumber":48,"sourceCode":"    private final String path;\n\n    public BigintDecoder(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            BIGINT.writeLong(output, ((Number) value).longValue());\n        }\n        else {\n            throw new PrestoException(ELASTICSEARCH_TYPE_MISMATCH, format(\"Expected a numeric value for field %s of type BIGINT: %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/BigintDecoder.java#L30-L52","documentation":"BigintDecoder decodes a field declared as BIGINT. A null decodes to NULL and a Number is written as a long, but any other JSON value (string, boolean, object) throws PrestoException(ELASTICSEARCH_TYPE_MISMATCH) — the document value cannot be coerced to BIGINT.","triggerScenarios":"A document stores a non-numeric value (e.g. \"age\": \"42\" as a string, or \"age\": true) in a field the Presto table declares as BIGINT; thrown while decoding rows during a scan.","commonSituations":"Dynamic mapping mapped the field as long in one document but later documents wrote strings; schema in Presto DDL does not match the ES mapping (keyword/text field declared as BIGINT); ingestion pipeline regression.","solutions":["Fix or reindex the offending documents so the field is numeric.","Correct the Presto column type in the schema to match the ES mapping (e.g. VARCHAR for keyword).","Add validation/coercion in the ingestion pipeline to guarantee numeric values.","Clean up documents with the bad value using update_by_query or a reindex script."],"exampleFix":"// before (document)\n{ \"user_id\": \"12345\" }\n// after\n{ \"user_id\": 12345 }","handlingStrategy":"validation","validationCode":"// find documents with non-numeric values in a BIGINT field\ncurl -s 'localhost:9200/<index>/_search' -H 'Content-Type: application/json' -d '{\n  \"query\": { \"bool\": { \"must_not\": [ { \"term\": { \"user_id\": { \"value\": 1 } } } ] } },\n  \"script_fields\": {} }'\n# better: use a script query checking isinstance(value, int) on user_id","typeGuard":null,"tryCatchPattern":"try {\n    rs = stmt.executeQuery(\"SELECT user_id FROM es.default.idx\");\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"ELASTICSEARCH_TYPE_MISMATCH\")) {\n        // locate and reindex documents where user_id is a string\n    } else { throw e; }\n}","preventionTips":["Declare Presto columns to match the ES mapping exactly.","Coerce types in the ingestion pipeline (numbers, not strings).","Spot-check documents with a script query after pipeline changes."],"tags":["elasticsearch","type-mismatch","decoder","bigint","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"}