elastic/elasticsearch · error · ParsingException

Unexpected token {token} [{currentFieldName}] in [{aggregati

Error message

Unexpected token {token} [{currentFieldName}] in [{aggregationName}].

What it means

Error "Unexpected token {token} [{currentFieldName}] in [{aggregationName}]." thrown in elastic/elasticsearch.

Source

Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/ArrayValuesSourceParser.java:91

            } else if (token == XContentParser.Token.VALUE_STRING) {
                if (CommonFields.FIELDS.match(currentFieldName, parser.getDeprecationHandler())) {
                    fields = Collections.singletonList(parser.text());
                } else if (formattable && CommonFields.FORMAT.match(currentFieldName, parser.getDeprecationHandler())) {
                    format = parser.text();
                } else if (CommonFields.VALUE_TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
                    throw new ParsingException(
                        parser.getTokenLocation(),
                        "Unexpected token "
                            + token
                            + " ["
                            + currentFieldName
                            + "] in ["
                            + aggregationName
                            + "]. "
                            + "Multi-field aggregations do not support scripts."
                    );
                } else if (token(aggregationName, currentFieldName, token, parser, otherOptions) == false) {
                    throw new ParsingException(
                        parser.getTokenLocation(),
                        "Unexpected token " + token + " [" + currentFieldName + "] in [" + aggregationName + "]."
                    );
                }
            } else if (token == XContentParser.Token.START_OBJECT) {
                if (CommonFields.MISSING.match(currentFieldName, parser.getDeprecationHandler())) {
                    missingMap = new HashMap<>();
                    while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
                        parseMissingAndAdd(aggregationName, currentFieldName, parser, missingMap);
                    }
                } else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
                    throw new ParsingException(
                        parser.getTokenLocation(),
                        "Unexpected token "
                            + token
                            + " ["
                            + currentFieldName
                            + "] in ["

View on GitHub (pinned to db6a809a66)

When it happens

Trigger: Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/ArrayValuesSourceParser.java:91 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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