elastic/elasticsearch · error · IllegalArgumentException
Member method [{}] does not exist for numeric field [{}].
Error message
Member method [{}] does not exist for numeric field [{}]. What it means
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.
Source
Thrown at modules/lang-expression/src/main/java/org/elasticsearch/script/expression/NumericField.java:61
case LENGTH_VARIABLE -> new CountMethodValueSource(fieldData);
default -> throw new IllegalArgumentException(
"Member variable [" + variable + "] does not exist for " + "numeric field [" + fieldName + "]."
);
};
}
static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
return switch (method) {
case GETVALUE_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case ISEMPTY_METHOD -> new EmptyMemberValueSource(fieldData);
case SIZE_METHOD -> new CountMethodValueSource(fieldData);
case MINIMUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case MAXIMUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MAX);
case AVERAGE_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.AVG);
case MEDIAN_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
case SUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.SUM);
case COUNT_METHOD -> new CountMethodValueSource(fieldData);
default -> throw new IllegalArgumentException(
"Member method [" + method + "] does not exist for numeric field [" + fieldName + "]."
);
};
}
}
View on GitHub (pinned to db6a809a66)
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
Example fix
// before — expression script source: doc['price'].getMin() // after — use the correct terse method name: doc['price'].min()
Defensive patterns
Strategy: validation
Validate before calling
// Validate numeric field methods before submission
Set<String> NUMERIC_METHODS = Set.of(
"getValue", "isEmpty", "size", "min", "max", "avg", "median", "sum", "count"
);
// extract method name from doc['field'].<method>() and verify membership Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Member variable [{}] does not exist for numeric field [{}].
- Member variable [{}] does not exist for geo field [{}].
- Member method [{}] does not exist for geo field [{}].
- Member variable [{}] does not exist for date field [{}].
- Member method [{}] does not exist for date field [{}].
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/5ffc5854507b41c6.
Report an issue: GitHub.