elastic/elasticsearch · error · IllegalArgumentException
Member variable [{}] does not exist for numeric field [{}].
Error message
Member variable [{}] does not exist for numeric field [{}]. What it means
Thrown by the lang-expression script engine when an expression references a member variable on a numeric field that is not one of the three supported names. Numeric fields expose exactly three member variables: 'value', 'empty', and 'length'. Any other member access on doc['<numeric_field>'].<variable> hits this default branch.
Source
Thrown at modules/lang-expression/src/main/java/org/elasticsearch/script/expression/NumericField.java:44
static final String LENGTH_VARIABLE = "length";
// supported methods
static final String GETVALUE_METHOD = "getValue";
static final String ISEMPTY_METHOD = "isEmpty";
static final String SIZE_METHOD = "size";
static final String MINIMUM_METHOD = "min";
static final String MAXIMUM_METHOD = "max";
static final String AVERAGE_METHOD = "avg";
static final String MEDIAN_METHOD = "median";
static final String SUM_METHOD = "sum";
static final String COUNT_METHOD = "count";
static DoubleValuesSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
return switch (variable) {
case VALUE_VARIABLE -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case EMPTY_VARIABLE -> new EmptyMemberValueSource(fieldData);
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 'value', 'empty', or 'length' as member variables on numeric fields: doc['price'].value (or just doc['price'] which defaults to .value)
- For statistics like min, max, avg, sum, use the method form: doc['price'].min(), doc['price'].max(), doc['price'].avg(), doc['price'].sum()
- Drop the member entirely for the default value: doc['price'] is equivalent to doc['price'].value
- Confirm the field is numeric via GET <index>/_mapping — non-numeric fields route to a different handler
Example fix
// before — expression script source: doc['price'].min // after — 'min' is a method, not a variable: doc['price'].min()
Defensive patterns
Strategy: validation
Validate before calling
// Validate numeric field member variables before submission
Set<String> NUMERIC_VARS = Set.of("value", "empty", "length");
// extract member after doc['field']. and verify it's in NUMERIC_VARS
// Note: doc['field'] without a member defaults to .value Prevention
- Remember: statistics like min, max, avg are METHODS not variables — they need parentheses
- Bare doc['field'] is equivalent to doc['field'].value
- Only value, empty, and length are valid as dot-syntax variables on numeric fields
When it happens
Trigger: Writing an expression script that accesses a numeric field with an unsupported member variable. Example: doc['price'].min or doc['price'].avg — these are methods, not variables. The variable name is parsed by VariableContext and routed to NumericField.getVariable only when the field data is IndexNumericFieldData.
Common situations: Confusing member variables (dot syntax, no parentheses) with member methods (parentheses). For example, doc['price'].min is a variable access that fails; doc['price'].min() is a method call that works. Expecting aggregation-like sub-fields (sum, avg, median) to be available as bare variables rather than methods. Misspelling 'value' as 'val'.
Related errors
- Member method [{}] 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/80f20c1e43fee231.
Report an issue: GitHub.