elastic/elasticsearch · error · IllegalArgumentException

Member method [{}] does not exist for date object on field [

Error message

Member method [{}] does not exist for date object on field [{}].

What it means

Thrown by DateObject.getMethod when an expression calls an unsupported member METHOD on a date OBJECT. Supported methods mirror the variables with a 'get' prefix: getCenturyOfEra, getDayOfMonth, getDayOfWeek, getDayOfYear, getEra, getHourOfDay, getMillisOfDay, getMillisOfSecond, getMinuteOfDay, getMinuteOfHour, getMonthOfYear, getSecondOfDay, getSecondOfMinute, getWeekOfWeekyear, getWeekyear, getYear, getYearOfCentury, getYearOfEra. Anything else is rejected.

Source

Thrown at modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateObject.java:213

                fieldData,
                MultiValueMode.MIN,
                method,
                zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())
            );
            case GETYEAR_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getYear);
            case GETYEAR_OF_CENTURY_METHOD -> new DateObjectValueSource(
                fieldData,
                MultiValueMode.MIN,
                method,
                zdt -> zdt.get(ChronoField.YEAR_OF_ERA) % 100
            );
            case GETYEAR_OF_ERA_METHOD -> new DateObjectValueSource(
                fieldData,
                MultiValueMode.MIN,
                method,
                zdt -> zdt.get(ChronoField.YEAR_OF_ERA)
            );
            default -> throw new IllegalArgumentException(
                "Member method [" + method + "] does not exist for date object on field [" + fieldName + "]."
            );
        };
    }
}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Use the exact get*-prefixed method name from the supported list.
  2. If you only need the value without calling a method, use the corresponding variable: doc['timestamp'].date.dayOfMonth.
  3. For unsupported components, derive them from supported accessors or index a precomputed field.

Example fix

// before
doc['timestamp'].date.getDay()

// after
doc['timestamp'].date.getDayOfMonth()
Defensive patterns

Strategy: validation

Validate before calling

Set<String> OK_METHODS = Set.of(
    "getCenturyOfEra","getDayOfMonth","getDayOfWeek","getDayOfYear","getEra",
    "getHourOfDay","getMillisOfDay","getMillisOfSecond","getMinuteOfDay",
    "getMinuteOfHour","getMonthOfYear","getSecondOfDay","getSecondOfMinute",
    "getWeekOfWeekyear","getWeekyear","getYear","getYearOfCentury","getYearOfEra");
if (!OK_METHODS.contains(method)) {
    throw new IllegalArgumentException("Unsupported date object method: " + method);
}

Prevention

When it happens

Trigger: Writing doc['timestamp'].date.<method>() with a method name not in the supported set, e.g. doc['timestamp'].date.getQuarter() or doc['timestamp'].date.getDay() (should be getDayOfMonth).

Common situations: Misspelling; using java.time method names; assuming a getter exists for an unsupported component.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/291a92a998ff7973. Report an issue: GitHub.