elastic/elasticsearch · error · ParsingException

Unexpected token {token} in [{reducerName}].

Error message

Unexpected token {token} in [{reducerName}].

What it means

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

Source

Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSelectorPipelineAggregationBuilder.java:152

                    );
                }
            } else if (token == XContentParser.Token.START_OBJECT) {
                if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
                    script = Script.parse(parser);
                } else if (BUCKETS_PATH.match(currentFieldName, parser.getDeprecationHandler())) {
                    Map<String, Object> map = parser.map();
                    bucketsPathsMap = new HashMap<>();
                    for (Map.Entry<String, Object> entry : map.entrySet()) {
                        bucketsPathsMap.put(entry.getKey(), String.valueOf(entry.getValue()));
                    }
                } else {
                    throw new ParsingException(
                        parser.getTokenLocation(),
                        "Unknown key for a " + token + " in [" + reducerName + "]: [" + currentFieldName + "]."
                    );
                }
            } else {
                throw new ParsingException(parser.getTokenLocation(), "Unexpected token " + token + " in [" + reducerName + "].");
            }
        }

        if (bucketsPathsMap == null) {
            throw new ParsingException(
                parser.getTokenLocation(),
                "Missing required field [" + BUCKETS_PATH.getPreferredName() + "] for bucket_selector aggregation [" + reducerName + "]"
            );
        }

        if (script == null) {
            throw new ParsingException(
                parser.getTokenLocation(),
                "Missing required field ["
                    + Script.SCRIPT_PARSE_FIELD.getPreferredName()
                    + "] for bucket_selector aggregation ["
                    + reducerName
                    + "]"

View on GitHub (pinned to db6a809a66)

When it happens

Trigger: Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSelectorPipelineAggregationBuilder.java:152 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/04f8cbe1df0a53ab. Report an issue: GitHub.