{"record":{"id":"291a92a998ff7973","repo":"elastic/elasticsearch","slug":"member-method-does-not-exist-for-date-object","errorCode":null,"errorMessage":"Member method [{}] does not exist for date object on field [{}].","messagePattern":"Member method \\[(.+?)\\] does not exist for date object on field \\[(.+?)\\]\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateObject.java","lineNumber":213,"sourceCode":"                fieldData,\n                MultiValueMode.MIN,\n                method,\n                zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())\n            );\n            case GETYEAR_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getYear);\n            case GETYEAR_OF_CENTURY_METHOD -> new DateObjectValueSource(\n                fieldData,\n                MultiValueMode.MIN,\n                method,\n                zdt -> zdt.get(ChronoField.YEAR_OF_ERA) % 100\n            );\n            case GETYEAR_OF_ERA_METHOD -> new DateObjectValueSource(\n                fieldData,\n                MultiValueMode.MIN,\n                method,\n                zdt -> zdt.get(ChronoField.YEAR_OF_ERA)\n            );\n            default -> throw new IllegalArgumentException(\n                \"Member method [\" + method + \"] does not exist for date object on field [\" + fieldName + \"].\"\n            );\n        };\n    }\n}\n","sourceCodeStart":195,"sourceCodeEnd":219,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateObject.java#L195-L219","documentation":"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.","triggerScenarios":"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).","commonSituations":"Misspelling; using java.time method names; assuming a getter exists for an unsupported component.","solutions":["Use the exact get*-prefixed method name from the supported list.","If you only need the value without calling a method, use the corresponding variable: doc['timestamp'].date.dayOfMonth.","For unsupported components, derive them from supported accessors or index a precomputed field."],"exampleFix":"// before\ndoc['timestamp'].date.getDay()\n\n// after\ndoc['timestamp'].date.getDayOfMonth()","handlingStrategy":"validation","validationCode":"Set<String> OK_METHODS = Set.of(\n    \"getCenturyOfEra\",\"getDayOfMonth\",\"getDayOfWeek\",\"getDayOfYear\",\"getEra\",\n    \"getHourOfDay\",\"getMillisOfDay\",\"getMillisOfSecond\",\"getMinuteOfDay\",\n    \"getMinuteOfHour\",\"getMonthOfYear\",\"getSecondOfDay\",\"getSecondOfMinute\",\n    \"getWeekOfWeekyear\",\"getWeekyear\",\"getYear\",\"getYearOfCentury\",\"getYearOfEra\");\nif (!OK_METHODS.contains(method)) {\n    throw new IllegalArgumentException(\"Unsupported date object method: \" + method);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Method names mirror variables with a 'get' prefix; use the exact spelling.","Cross-check against the supported list when constructing dynamic expressions.","If a getter is missing, fall back to the variable form (doc['f'].date.dayOfMonth)."],"tags":["elasticsearch","lang-expression","expression-script","date-object","method","validation"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}