{"record":{"id":"1befa37c55f63b30","repo":"elastic/elasticsearch","slug":"cannot-use-stored-scripts-in-tokenfilter-name-1befa3","errorCode":null,"errorMessage":"Cannot use stored scripts in tokenfilter [{name}]","messagePattern":"Cannot use stored scripts in tokenfilter \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterFactory.java","lineNumber":45,"sourceCode":"import java.util.List;\nimport java.util.function.Function;\n\n/**\n * A factory for a conditional token filter that only applies child filters if the underlying token\n * matches an {@link AnalysisPredicateScript}\n */\npublic class ScriptedConditionTokenFilterFactory extends AbstractTokenFilterFactory {\n\n    private final AnalysisPredicateScript.Factory factory;\n    private final List<String> filterNames;\n\n    ScriptedConditionTokenFilterFactory(IndexSettings indexSettings, String name, Settings settings, ScriptService scriptService) {\n        super(name);\n\n        Settings scriptSettings = settings.getAsSettings(\"script\");\n        Script script = Script.parse(scriptSettings);\n        if (script.getType() != ScriptType.INLINE) {\n            throw new IllegalArgumentException(\"Cannot use stored scripts in tokenfilter [\" + name + \"]\");\n        }\n        this.factory = scriptService.compile(script, AnalysisPredicateScript.CONTEXT);\n\n        this.filterNames = settings.getAsList(\"filter\");\n        if (this.filterNames.isEmpty()) {\n            throw new IllegalArgumentException(\"Empty list of filters provided to tokenfilter [\" + name + \"]\");\n        }\n    }\n\n    @Override\n    public TokenStream create(TokenStream tokenStream) {\n        throw new UnsupportedOperationException(\"getChainAwareTokenFilterFactory should be called first\");\n    }\n\n    @Override\n    public TokenFilterFactory getChainAwareTokenFilterFactory(\n        IndexCreationContext context,\n        TokenizerFactory tokenizer,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterFactory.java#L27-L63","documentation":"Error \"Cannot use stored scripts in tokenfilter [{name}]\" thrown in elastic/elasticsearch.","triggerScenarios":"Thrown at modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterFactory.java:45 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}