languagetool-org/languagetool · error · UnsupportedPatternRuleException

Elements with only match references (e.g. \1) are not suppor

Error message

Elements with only match references (e.g. \1) are not supported.

What it means

Search-index guard in checkUnsupportedElement: the pattern element contains only back-references like \1 and no term or POS of its own, so nothing indexable remains for Lucene.

Source

Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:252

      }
      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

  1. Add a term or POS tag to the element
  2. Skip the rule when building index queries
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/index/PatternRuleQueryBuilder.java:252 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/542c2100cfa94d8c. Report an issue: GitHub.