elastic/elasticsearch · error · IllegalArgumentException

Member variable [{}] does not exist for geo field [{}].

Error message

Member variable [{}] does not exist for geo field [{}].

What it means

Thrown by the lang-expression script engine when an expression references a member variable on a geo_point field that is not one of the three supported names. Geo fields expose exactly three member variables: 'empty', 'lat', and 'lon'. Any other member access on doc['<geo_field>'].<variable> hits this default branch in the switch statement.

Source

Thrown at modules/lang-expression/src/main/java/org/elasticsearch/script/expression/GeoField.java:37

    // no instance
    private GeoField() {}

    // supported variables
    static final String EMPTY_VARIABLE = "empty";
    static final String LAT_VARIABLE = "lat";
    static final String LON_VARIABLE = "lon";

    // supported methods
    static final String ISEMPTY_METHOD = "isEmpty";
    static final String GETLAT_METHOD = "getLat";
    static final String GETLON_METHOD = "getLon";

    static DoubleValuesSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
        return switch (variable) {
            case EMPTY_VARIABLE -> new GeoEmptyValueSource(fieldData);
            case LAT_VARIABLE -> new GeoLatitudeValueSource(fieldData);
            case LON_VARIABLE -> new GeoLongitudeValueSource(fieldData);
            default -> throw new IllegalArgumentException(
                "Member variable [" + variable + "] does not exist for geo field [" + fieldName + "]."
            );
        };
    }

    static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
        return switch (method) {
            case ISEMPTY_METHOD -> new GeoEmptyValueSource(fieldData);
            case GETLAT_METHOD -> new GeoLatitudeValueSource(fieldData);
            case GETLON_METHOD -> new GeoLongitudeValueSource(fieldData);
            default -> throw new IllegalArgumentException(
                "Member method [" + method + "] does not exist for geo field [" + fieldName + "]."
            );
        };
    }
}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Use only 'lat', 'lon', or 'empty' as member variables on geo_point fields: doc['location'].lat, doc['location'].lon, doc['location'].empty
  2. If you need a method-style access, use the method forms: doc['location'].getLat(), doc['location'].getLon(), doc['location'].isEmpty()
  3. If you need geo distance or geohash computation, use a painless script or a dedicated geo query/aggregation instead of the expression language
  4. Check the field mapping with GET <index>/_mapping to confirm the field is actually geo_point

Example fix

// before — expression script source:
doc['location'].altitude

// after — use the supported member variable:
doc['location'].lat
Defensive patterns

Strategy: validation

Validate before calling

// Validate expression script geo field member variables before submission
Set<String> GEO_VARS = Set.of("empty", "lat", "lon");
String extractMember(String exprRef) {
    // extract the member after doc['field'].
    int dot = exprRef.lastIndexOf('.');
    return dot >= 0 ? exprRef.substring(dot + 1) : "value";
}
// before sending: assert GEO_VARS.contains(extractMember(variableRef))

Prevention

When it happens

Trigger: Writing an expression script ("source": "expression", e.g. in a script_score, sort, or aggregation) that accesses a geo_point field with an unsupported member variable. Example: doc['location'].altitude or doc['location'].geohash where 'location' is mapped as geo_point. The variable name is parsed by VariableContext and routed to GeoField.getVariable only when the field type is GeoPointFieldType.

Common situations: Assuming geo_point fields expose arbitrary sub-fields like geohash, altitude, or distance. Copying an expression from a numeric or date field example without adjusting for the geo API. Misspelling 'lat' or 'lon' (e.g., 'latitude'). Confusing member variables (dot syntax) with member methods (parenthesis syntax).

Related errors


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