elastic/elasticsearch · error · IllegalArgumentException

Token filter [{filterName}] refers to itself, either directl

Error message

Token filter [{filterName}] refers to itself, either directly or via a cycle of filters {expansionPath}

What it means

Error "Token filter [{filterName}] refers to itself, either directly or via a cycle of filters {expansionPath}" thrown in elastic/elasticsearch.

Source

Thrown at modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/ReferringFilterResolver.java:56

    public TokenFilterFactory apply(String name) {
        return delegate.apply(name);
    }

    /**
     * Records that the referring filter {@code filterName} is about to expand the filters it refers
     * to, returning a resolver to use for that expansion. Throws {@link IllegalArgumentException} if
     * {@code filterName} is already being expanded higher up the chain, which indicates a reference
     * cycle.
     *
     * @param filterName the name of the referring token filter (e.g. a {@code multiplexer} or
     *                   {@code condition} filter) that is about to rewrite its referenced filters
     * @param allFilters the {@code allFilters} lookup received by the referring filter, which may
     *                   itself be a {@link ReferringFilterResolver} created by an ancestor
     */
    static ReferringFilterResolver enter(String filterName, Function<String, TokenFilterFactory> allFilters) {
        if (allFilters instanceof ReferringFilterResolver resolver) {
            if (resolver.expansionPath.contains(filterName)) {
                throw new IllegalArgumentException(
                    "Token filter ["
                        + filterName
                        + "] refers to itself, either directly or via a cycle of filters "
                        + resolver.expansionPath
                );
            }
            Set<String> nextPath = new LinkedHashSet<>(resolver.expansionPath);
            nextPath.add(filterName);
            return new ReferringFilterResolver(resolver.delegate, nextPath);
        }
        Set<String> path = new LinkedHashSet<>();
        path.add(filterName);
        return new ReferringFilterResolver(allFilters, path);
    }
}

View on GitHub (pinned to db6a809a66)

When it happens

Trigger: Thrown at modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/ReferringFilterResolver.java:56 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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