{"record":{"id":"590bad79208bd242","repo":"elastic/elasticsearch","slug":"invalid-mapping-rule-rule-illegal-type","errorCode":null,"errorMessage":"Invalid Mapping Rule : [{rule}]. Illegal type.","messagePattern":"Invalid Mapping Rule : \\[(.+?)\\]\\. Illegal type\\.","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java","lineNumber":122,"sourceCode":"    }\n\n    // source => type\n    private static final Pattern typePattern = Pattern.compile(\"(.*)\\\\s*=>\\\\s*(.*)\\\\s*$\");\n\n    /**\n     * parses a list of MappingCharFilter style rules into a custom byte[] type table\n     */\n    static byte[] parseTypes(Collection<String> rules) {\n        SortedMap<Character, Byte> typeMap = new TreeMap<>();\n        for (String rule : rules) {\n            Matcher m = typePattern.matcher(rule);\n            if (m.find() == false) {\n                throw new RuntimeException(\"Invalid Mapping Rule : [\" + rule + \"]\");\n            }\n            String lhs = parseString(m.group(1).trim());\n            Byte rhs = parseType(m.group(2).trim());\n            if (lhs.length() != 1) throw new RuntimeException(\"Invalid Mapping Rule : [\" + rule + \"]. Only a single character is allowed.\");\n            if (rhs == null) throw new RuntimeException(\"Invalid Mapping Rule : [\" + rule + \"]. Illegal type.\");\n            typeMap.put(lhs.charAt(0), rhs);\n        }\n\n        // ensure the table is always at least as big as DEFAULT_WORD_DELIM_TABLE for performance\n        byte types[] = new byte[Math.max(typeMap.lastKey() + 1, WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE.length)];\n        for (int i = 0; i < types.length; i++) {\n            types[i] = WordDelimiterIterator.getType(i);\n        }\n        for (Map.Entry<Character, Byte> mapping : typeMap.entrySet()) {\n            types[mapping.getKey()] = mapping.getValue();\n        }\n        return types;\n    }\n\n    private static Byte parseType(String s) {\n        if (s.equals(\"LOWER\")) return WordDelimiterFilter.LOWER;\n        else if (s.equals(\"UPPER\")) return WordDelimiterFilter.UPPER;\n        else if (s.equals(\"ALPHA\")) return WordDelimiterFilter.ALPHA;","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java#L104-L140","documentation":"The right-hand side of a type_table rule must be one of the recognised type identifiers (parseType returns a Byte for known names and null otherwise). When parseType returns null, parseTypes throws RuntimeException. Known names include LOWER, UPPER, ALPHA, DIGIT, SUBWORD_DELIM (and a few others) — anything else is rejected.","triggerScenarios":"A type_table entry whose RHS is not a valid type constant: \"- => PUNCT\", \"- => lower\", \"- => DASH\".","commonSituations":"Typo in the type name; using lowercase; inventing a type that does not exist in WordDelimiterFilter.","solutions":["Use one of the recognised type names (LOWER, UPPER, ALPHA, DIGIT, SUBWORD_DELIM) on the RHS.","Match the casing exactly (these are uppercase constants).","Re-run the index/template create."],"exampleFix":"// before\n\"type_table\": [\"- => PUNCT\"]\n// after\n\"type_table\": [\"- => SUBWORD_DELIM\"]","handlingStrategy":"validation","validationCode":"static final Set<String> VALID_TYPES = Set.of(\"LOWER\",\"UPPER\",\"ALPHA\",\"DIGIT\",\"SUBWORD_DELIM\");\nstatic List<String> badRhs(List<String> typeTable) {\n  return typeTable.stream()\n    .map(r -> r.split(\"=>\", 2)[1].trim())\n    .filter(rhs -> !VALID_TYPES.contains(rhs))\n    .toList();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check RHS against WordDelimiterFilter type constants (LOWER, UPPER, ALPHA, DIGIT, SUBWORD_DELIM).","These constants are uppercase; case-sensitive."],"tags":["analysis","word-delimiter","type-table","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}