{"record":{"id":"f2858eebdd451349","repo":"elastic/elasticsearch","slug":"member-method-does-not-exist-for-geo-field","errorCode":null,"errorMessage":"Member method [{}] does not exist for geo field [{}].","messagePattern":"Member method \\[(.+?)\\] does not exist for geo field \\[(.+?)\\]\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/lang-expression/src/main/java/org/elasticsearch/script/expression/GeoField.java","lineNumber":48,"sourceCode":"    static final String GETLON_METHOD = \"getLon\";\n\n    static DoubleValuesSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {\n        return switch (variable) {\n            case EMPTY_VARIABLE -> new GeoEmptyValueSource(fieldData);\n            case LAT_VARIABLE -> new GeoLatitudeValueSource(fieldData);\n            case LON_VARIABLE -> new GeoLongitudeValueSource(fieldData);\n            default -> throw new IllegalArgumentException(\n                \"Member variable [\" + variable + \"] does not exist for geo field [\" + fieldName + \"].\"\n            );\n        };\n    }\n\n    static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {\n        return switch (method) {\n            case ISEMPTY_METHOD -> new GeoEmptyValueSource(fieldData);\n            case GETLAT_METHOD -> new GeoLatitudeValueSource(fieldData);\n            case GETLON_METHOD -> new GeoLongitudeValueSource(fieldData);\n            default -> throw new IllegalArgumentException(\n                \"Member method [\" + method + \"] does not exist for geo field [\" + fieldName + \"].\"\n            );\n        };\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":54,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/GeoField.java#L30-L54","documentation":"Thrown by the lang-expression script engine when an expression calls a member method on a geo_point field that is not supported. Geo fields expose exactly three methods: 'isEmpty()', 'getLat()', and 'getLon()'. Any other method invocation on doc['<geo_field>'].<method>() hits this default branch.","triggerScenarios":"Writing an expression script that calls an unsupported method on a geo_point field. Example: doc['location'].getAltitude() or doc['location'].distance(). The method name is parsed by VariableContext as a METHOD-type context part and routed to GeoField.getMethod when the field type is GeoPointFieldType.","commonSituations":"Expecting geo helper methods like distanceTo, within, or getGeohash that do not exist in the expression engine. Confusing the expression language's limited geo API with painless's richer API. Copying method names from date fields (e.g., getYear) onto geo fields.","solutions":["Use only getLat(), getLon(), or isEmpty() as methods on geo_point fields","If you prefer variable-style access without parentheses, use doc['location'].lat / .lon / .empty","For geo distance calculations, use a painless script or the geo_distance query/aggregation","Verify the field type with GET <index>/_mapping — this error only applies to geo_point fields"],"exampleFix":"// before — expression script source:\ndoc['location'].getAltitude()\n\n// after — use a supported method:\ndoc['location'].getLat()","handlingStrategy":"validation","validationCode":"// Validate expression script geo field methods before submission\nSet<String> GEO_METHODS = Set.of(\"isEmpty\", \"getLat\", \"getLon\");\n// extract method name from doc['field'].<method>() and check membership","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Geo methods require parentheses: doc['field'].getLat(), not doc['field'].getLat","Only three methods exist: isEmpty(), getLat(), getLon()","Prefer variable syntax (.lat, .lon) for readability when you don't need method form"],"tags":["elasticsearch","lang-expression","geo-point","script","expression"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}