{"record":{"id":"5ffc5854507b41c6","repo":"elastic/elasticsearch","slug":"member-method-does-not-exist-for-numeric-fiel","errorCode":null,"errorMessage":"Member method [{}] does not exist for numeric field [{}].","messagePattern":"Member method \\[(.+?)\\] does not exist for numeric field \\[(.+?)\\]\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/lang-expression/src/main/java/org/elasticsearch/script/expression/NumericField.java","lineNumber":61,"sourceCode":"            case LENGTH_VARIABLE -> new CountMethodValueSource(fieldData);\n            default -> throw new IllegalArgumentException(\n                \"Member variable [\" + variable + \"] does not exist for \" + \"numeric field [\" + fieldName + \"].\"\n            );\n        };\n    }\n\n    static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {\n        return switch (method) {\n            case GETVALUE_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);\n            case ISEMPTY_METHOD -> new EmptyMemberValueSource(fieldData);\n            case SIZE_METHOD -> new CountMethodValueSource(fieldData);\n            case MINIMUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);\n            case MAXIMUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MAX);\n            case AVERAGE_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.AVG);\n            case MEDIAN_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);\n            case SUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.SUM);\n            case COUNT_METHOD -> new CountMethodValueSource(fieldData);\n            default -> throw new IllegalArgumentException(\n                \"Member method [\" + method + \"] does not exist for numeric field [\" + fieldName + \"].\"\n            );\n        };\n    }\n}\n","sourceCodeStart":43,"sourceCodeEnd":67,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/NumericField.java#L43-L67","documentation":"Thrown by the lang-expression script engine when an expression calls a member method on a numeric field that is not one of the nine supported methods. Numeric fields expose: getValue(), isEmpty(), size(), min(), max(), avg(), median(), sum(), and count(). Any other method invocation on doc['<numeric_field>'].<method>() hits this default branch.","triggerScenarios":"Writing an expression script that calls an unsupported method on a numeric field. Example: doc['price'].getMin() (note: it's 'min', not 'getMin'), doc['price'].average() (it's 'avg'), or doc['price'].stddev(). The method name is parsed by VariableContext as a METHOD-type context and routed to NumericField.getMethod when IndexNumericFieldData is detected.","commonSituations":"Using verbose Java-style names (getMin, getMaximum) instead of the terse forms (min, max). Expecting statistical methods not supported by the expression engine (stddev, variance, percentile). Confusing numeric field methods with date field methods (getYear, getHour). Copying method names from painless that have no expression equivalent.","solutions":["Use only the supported method names: getValue(), isEmpty(), size(), min(), max(), avg(), median(), sum(), count()","Check spelling: it's 'avg' not 'average', 'min' not 'getMin', 'median' not 'med'","For unsupported statistics (stddev, percentiles), use painless or a metrics aggregation instead","Verify the field is numeric with GET <index>/_mapping"],"exampleFix":"// before — expression script source:\ndoc['price'].getMin()\n\n// after — use the correct terse method name:\ndoc['price'].min()","handlingStrategy":"validation","validationCode":"// Validate numeric field methods before submission\nSet<String> NUMERIC_METHODS = Set.of(\n    \"getValue\", \"isEmpty\", \"size\", \"min\", \"max\", \"avg\", \"median\", \"sum\", \"count\"\n);\n// extract method name from doc['field'].<method>() and verify membership","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Method names are terse: 'avg' not 'average', 'min' not 'getMin'","Nine supported methods: getValue, isEmpty, size, min, max, avg, median, sum, count","Always include parentheses for method calls in expressions"],"tags":["elasticsearch","lang-expression","numeric","script","expression"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}