languagetool-org/languagetool · error · UnsupportedPatternRuleException
<or> not yet supported.
Error message
<or> not yet supported.
What it means
Search-index guard in checkUnsupportedElement: the pattern token is part of an <or> token group, which the query builder cannot map to Lucene clauses yet.
Source
Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:246
Term newTerm = new Term(term.field(), simplifyRegex(term.text()));
return new RegexpQuery(newTerm);
}
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
- Flatten the <or> group into separate rules or alternatives
- Skip the rule for index-based search
- Extend the builder to handle or-groups
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:246 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/dbfe5c1c3ff661fa.
Report an issue: GitHub.