languagetool-org/languagetool · error · UnsupportedPatternRuleException
Elements with unified tokens are not supported.
Error message
Elements with unified tokens are not supported.
What it means
Search-index guard in checkUnsupportedElement: the pattern token uses unified (matching) tokens, whose cross-token agreement semantics cannot be expressed in a Lucene query.
Source
Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:249
if (str.contains("?iu") || str.contains("?-i")) {
// Lucene's RegexpQuery doesn't seem to support this
throw new UnsupportedPatternRuleException("Regex constructs like '?iu' and '?-i' are not supported: " + patternToken);
}
return new RegexpQuery(term);
} catch (IllegalArgumentException e) {
// constructs like "\p{Punct}" not supported by Lucene RegExp:
throw new UnsupportedPatternRuleException("Advanced regex like '\\p{Punct}' are not supported: " + patternToken);
}
}
private void checkUnsupportedElement(PatternToken patternPatternToken)
throws UnsupportedPatternRuleException {
if (patternPatternToken.hasOrGroup()) {
// TODO: this is not enough: the first of the tokens in the <or> group will not get into this branch
throw new UnsupportedPatternRuleException("<or> not yet supported.");
}
if (patternPatternToken.isUnified()) {
throw new UnsupportedPatternRuleException("Elements with unified tokens are not supported.");
}
if (patternPatternToken.getString() != null && patternPatternToken.getString().matches("\\\\\\d+")) { // e.g. "\1"
throw new UnsupportedPatternRuleException("Elements with only match references (e.g. \\1) are not supported.");
}
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Remove unification from the element for indexing purposes
- Skip the rule during index-based checking
- Post-filter matches with the full rule engine after a relaxed index query
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:249 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/8d05033072790f4e.
Report an issue: GitHub.