{"record":{"id":"5a543eba3c0a48b2","repo":"elastic/elasticsearch","slug":"update-offsets-is-not-supported-anymore-please-fi","errorCode":null,"errorMessage":"update_offsets is not supported anymore. Please fix your analysis chain","messagePattern":"update_offsets is not supported anymore\\. Please fix your analysis chain","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/TrimTokenFilterFactory.java","lineNumber":27,"sourceCode":"\npackage org.elasticsearch.analysis.common;\n\nimport org.apache.lucene.analysis.TokenStream;\nimport org.apache.lucene.analysis.miscellaneous.TrimFilter;\nimport org.elasticsearch.common.settings.Settings;\nimport org.elasticsearch.env.Environment;\nimport org.elasticsearch.index.IndexSettings;\nimport org.elasticsearch.index.analysis.AbstractTokenFilterFactory;\nimport org.elasticsearch.index.analysis.NormalizingTokenFilterFactory;\n\npublic class TrimTokenFilterFactory extends AbstractTokenFilterFactory implements NormalizingTokenFilterFactory {\n\n    private static final String UPDATE_OFFSETS_KEY = \"update_offsets\";\n\n    TrimTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {\n        super(name);\n        if (settings.get(UPDATE_OFFSETS_KEY) != null) {\n            throw new IllegalArgumentException(UPDATE_OFFSETS_KEY + \" is not supported anymore. Please fix your analysis chain\");\n        }\n    }\n\n    @Override\n    public TokenStream create(TokenStream tokenStream) {\n        return new TrimFilter(tokenStream);\n    }\n\n}\n","sourceCodeStart":9,"sourceCodeEnd":37,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/TrimTokenFilterFactory.java#L9-L37","documentation":"The trim token filter no longer supports the update_offsets option — Lucene's TrimFilter always shifts offsets, and the legacy flag was removed. The constructor performs an explicit settings.get(\"update_offsets\") presence check and rejects any value (true or false) with IllegalArgumentException. There is no migration path: the option must be removed.","triggerScenarios":"Defining an analyzer with a filter of type 'trim' whose settings include the key 'update_offsets' with any value. Reproduced on index create, index settings update, template apply, or _analyze.","commonSituations":"Carrying forward an analyzer definition from a pre-7.x or Lucene-5.x cluster; copy-pasting a tutorial that still mentions update_offsets; CI failing after a cluster upgrade because the option was removed in a recent version.","solutions":["Delete the \"update_offsets\" key from the trim filter definition.","If offset preservation is genuinely required, redesign the analysis chain (e.g. use a char filter or a different token filter) rather than trying to restore the flag.","Re-run the index/template create after the edit."],"exampleFix":"// before\n\"filter\": { \"my_trim\": { \"type\": \"trim\", \"update_offsets\": \"true\" } }\n// after\n\"filter\": { \"my_trim\": { \"type\": \"trim\" } }","handlingStrategy":"validation","validationCode":"// Strip the removed flag from any trim filter before sending\nstatic void sanitize(Map<String,Object> filter) {\n  if (\"trim\".equals(filter.get(\"type\"))) {\n    filter.remove(\"update_offsets\");\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Audit analyzer definitions for update_offsets whenever upgrading across major versions.","Keep analyzer config under version control and lint for removed keys in CI."],"tags":["analysis","deprecation","configuration","upgrade"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}