{"record":{"id":"a50466bf09c99be4","repo":"elastic/elasticsearch","slug":"error-evaluating-a50466","errorCode":null,"errorMessage":"Error evaluating {}","messagePattern":"Error evaluating (.+?)","errorType":"exception","errorClass":"GeneralScriptException","httpStatus":null,"severity":"error","filePath":"modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionFieldScript.java","lineNumber":43,"sourceCode":"\n    ExpressionFieldScript(Expression e, SimpleBindings b) {\n        this.exprScript = e;\n        this.source = exprScript.getDoubleValuesSource(b);\n    }\n\n    @Override\n    public FieldScript newInstance(final LeafReaderContext leaf) throws IOException {\n        return new FieldScript() {\n\n            // Fake the scorer until setScorer is called.\n            DoubleValues values = source.getValues(leaf, null);\n\n            @Override\n            public Object execute() {\n                try {\n                    return values.doubleValue();\n                } catch (Exception exception) {\n                    throw new GeneralScriptException(\"Error evaluating \" + exprScript, exception);\n                }\n            }\n\n            @Override\n            public void setDocument(int d) {\n                try {\n                    values.advanceExact(d);\n                } catch (IOException e) {\n                    throw new IllegalStateException(\"Can't advance to doc using \" + exprScript, e);\n                }\n            }\n        };\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":58,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionFieldScript.java#L25-L58","documentation":"Thrown as GeneralScriptException by ExpressionFieldScript.execute when doubleValue() raises any Exception while evaluating a field-level expression script (runtime_field or script_fields). The compiled Expression source is included in the message and the original exception is the cause. This is the field-script counterpart of error 1214.","triggerScenarios":"Using a lang: expression script in script_fields or as a runtime field where evaluating the expression per document throws - e.g. referencing a non-numeric field, a field without doc_values, or an unbound variable.","commonSituations":"Referencing a text/keyword field in a numeric expression; field with doc_values disabled; typo in field name producing an unbound variable; using an expression on a field type the engine can't read numerically.","solutions":["Read the wrapped cause to find the specific failure (unbound variable, missing doc_values, etc.).","Ensure referenced fields are numeric with doc_values enabled.","For runtime fields on non-numeric data, switch to lang: painless."],"exampleFix":"// before: script_fields references a keyword field\n{\"script_fields\": {\"calc\": {\"script\": {\"source\": \"doc['tags'].value * 2\", \"lang\": \"expression\"}}}}\n\n// after: reference a numeric field\n{\"script_fields\": {\"calc\": {\"script\": {\"source\": \"doc['price'].value * 2\", \"lang\": \"expression\"}}}}","handlingStrategy":"try-catch","validationCode":"// Before using a field in a script_fields/runtime expression, confirm numeric doc_values\nGetMappingsResponse m = client.indices().getMappings(s -> s.index(idx)).result();\n// ensure the referenced field is numeric with doc_values=true","typeGuard":null,"tryCatchPattern":"try {\n    // script_fields / runtime field query with expression\n} catch (GeneralScriptException e) {\n    // e.getCause() holds the real reason; log and surface to caller\n    log.warn(\"field expression failed\", e.getCause());\n    throw e;\n}","preventionTips":["Reference only numeric, doc_values-enabled fields in field-level expression scripts.","Use painless for non-numeric or complex runtime field logic.","Inspect the wrapped cause to pinpoint unbound variables or missing doc_values."],"tags":["elasticsearch","lang-expression","expression-script","field-script","runtime"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}