languagetool-org/languagetool · error · UnsupportedPatternRuleException
Term/POS combination not supported yet: + patternToken
Error message
Term/POS combination not supported yet: + patternToken
What it means
Search-index guard in makeQuery: the pattern element's combination of literal term and POS tag cannot be expressed as a Lucene query for the index; the specific token is included in the message.
Source
Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:109
private BooleanClause makeQuery(PatternToken patternToken) throws UnsupportedPatternRuleException {
checkUnsupportedElement(patternToken);
String termStr = patternToken.getString();
String pos = patternToken.getPOStag();
BooleanClause termQuery = getTermQueryOrNull(patternToken, termStr);
BooleanClause posQuery = getPosQueryOrNull(patternToken, pos);
if (termQuery != null && posQuery != null) {
// if both term and POS are set, we create a query where both are at the same position
if (mustOccur(termQuery) && mustOccur(posQuery)) {
SpanQuery spanQueryForTerm = asSpanQuery(termQuery);
SpanQuery spanQueryForPos = asSpanQuery(posQuery);
SpanQuery[] spanClauses = {spanQueryForTerm, spanQueryForPos};
return new BooleanClause(new SpanNearQuery(spanClauses, 0, false), BooleanClause.Occur.MUST);
} else {
// should not happen, we always use Occur.MUST:
throw new UnsupportedPatternRuleException("Term/POS combination not supported yet: " + patternToken);
}
} else if (termQuery != null) {
return termQuery;
} else if (posQuery != null) {
return posQuery;
}
throw new UnsupportedPatternRuleException("Neither POS tag nor term set for element: " + patternToken);
}
private SpanQuery asSpanQuery(BooleanClause query) {
if (query.getQuery() instanceof MultiTermQuery) {
return new SpanMultiTermQueryWrapper<>((MultiTermQuery) query.getQuery());
} else {
Set<Term> terms = new HashSet<>();
try {
indexSearcher.createWeight(query.getQuery(), false).extractTerms(terms);View on GitHub (pinned to 2e990059ce)
Solutions
- Use only a term or only a POS tag on that element
- Relax the token (e.g. drop inflection or chunk constraints)
- Skip the rule during index-based search
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:109 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/998f348ea6b7cfda.
Report an issue: GitHub.