elastic/elasticsearch · error · IllegalArgumentException
Member variable [{}] does not exist for date object on field
Error message
Member variable [{}] does not exist for date object on field [{}]. What it means
Thrown by DateObject.getVariable when an expression references an unsupported member VARIABLE on a date OBJECT (doc['<dateField>'].date.<var>). DateObject exposes a fixed vocabulary of Joda-style variables: centuryOfEra, dayOfMonth, dayOfWeek, dayOfYear, era, hourOfDay, millisOfDay, millisOfSecond, minuteOfDay, minuteOfHour, monthOfYear, secondOfDay, secondOfMinute, weekOfWeekyear, weekyear, year, yearOfCentury, yearOfEra. Anything else is rejected.
Source
Thrown at modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateObject.java:137
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())
);
case YEAR_VARIABLE -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getYear);
case YEAR_OF_CENTURY_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(ChronoField.YEAR_OF_ERA) % 100
);
case YEAR_OF_ERA_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(ChronoField.YEAR_OF_ERA)
);
default -> throw new IllegalArgumentException(
"Member variable [" + variable + "] does not exist for date object on field [" + fieldName + "]."
);
};
}
static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
return switch (method) {
case GETCENTURY_OF_ERA_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(ChronoField.YEAR_OF_ERA) / 100
);
case GETDAY_OF_MONTH_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getDayOfMonth);
case GETDAY_OF_WEEK_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,View on GitHub (pinned to db6a809a66)
Solutions
- Use the exact Joda-style variable name from the supported list (e.g. dayOfMonth, monthOfYear, yearOfEra).
- For methods, use the get*-prefixed form: doc['timestamp'].date.getDayOfMonth().
- If the component is unsupported (e.g. quarter), compute it from supported pieces or index a derived field.
Example fix
// before doc['timestamp'].date.millis // after doc['timestamp'].date.millisOfSecond
Defensive patterns
Strategy: validation
Validate before calling
Set<String> OK = Set.of(
"centuryOfEra","dayOfMonth","dayOfWeek","dayOfYear","era","hourOfDay",
"millisOfDay","millisOfSecond","minuteOfDay","minuteOfHour","monthOfYear",
"secondOfDay","secondOfMinute","weekOfWeekyear","weekyear","year",
"yearOfCentury","yearOfEra");
if (!OK.contains(variable)) {
throw new IllegalArgumentException("Unsupported date object variable: " + variable);
} Prevention
- Use Joda-style variable names (e.g. monthOfYear, not monthValue).
- Note some components like 'quarter' are unsupported - derive them or precompute.
- Variable names are case-sensitive; match them exactly.
When it happens
Trigger: Writing doc['timestamp'].date.<var> where <var> is misspelled or not in the supported set, e.g. doc['timestamp'].date.millis (correct: millisOfSecond) or doc['timestamp'].date.quarter (quarters are not supported).
Common situations: Typos; using java.time field names instead of the Joda-style names the engine expects; expecting a component (like quarter) that the engine never implemented.
Related errors
- Member method [{}] does not exist for date object on field [
- Member variable [{}] does not exist for date field [{}].
- Member method [{}] does not exist for date field [{}].
- Error evaluating {}
- Can't advance to doc using {}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/ea458cb4b66dd6ad.
Report an issue: GitHub.