languagetool-org/languagetool · error · UnsupportedPatternRuleException
No items found in rule that can be used to build a search qu
Error message
No items found in rule that can be used to build a search query: + rule
What it means
Search-index guard in buildRelaxedQuery: none of the rule's pattern tokens yielded a usable Lucene clause (all were unsupported or empty), so the resulting BooleanQuery would match nothing.
Source
Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:86
* Iterate over all elements, ignore those not supported, add the other ones to a BooleanQuery.
* @throws UnsupportedPatternRuleException if no query could be created for the rule
*/
public Query buildRelaxedQuery(AbstractPatternRule rule) throws UnsupportedPatternRuleException {
BooleanQuery.Builder builder = new BooleanQuery.Builder();
for (PatternToken patternToken : rule.getPatternTokens()) {
try {
BooleanClause clause = makeQuery(patternToken);
builder.add(clause);
} catch (UnsupportedPatternRuleException e) {
//System.out.println("Ignoring because it's not supported: " + element + ": " + e);
// cannot handle - okay to ignore, as we may return too broad matches
} catch (Exception e) {
throw new RuntimeException("Could not create query for rule " + rule.getId(), e);
}
}
BooleanQuery query = builder.build();
if (query.clauses().isEmpty()) {
throw new UnsupportedPatternRuleException("No items found in rule that can be used to build a search query: " + rule);
}
return query;
}
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);View on GitHub (pinned to 2e990059ce)
Solutions
- Give the rule at least one token with a term or POS tag
- Skip this rule when indexing; it cannot be searched with the current builder
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:86 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/4657f05596cb4b43.
Report an issue: GitHub.