spring-projects/spring-ai · error · UnsupportedOperationException
Not supported expression type:
Error message
Not supported expression type:
What it means
S3VectorFilterSearchExpressionConverter.getOperationSymbol throws UnsupportedOperationException when a Filter.ExpressionType has no S3 Vectors operator mapping. Only AND, NOT, OR, EQ, NE, LT, LTE, GT, GTE, NIN, IN are supported; anything else (e.g. types added in newer Spring AI versions) falls through to the default branch.
Source
Thrown at vector-stores/spring-ai-s3-vector-store/src/main/java/org/springframework/ai/vectorstore/s3/S3VectorFilterSearchExpressionConverter.java:59
public S3VectorFilterSearchExpressionConverter() {
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
}
private String getOperationSymbol(Filter.ExpressionType exp) {
return switch (exp) {
case AND -> "$and";
case NOT -> "$not";
case OR -> "$or";
case EQ -> "$eq";
case NE -> "$ne";
case LT -> "$lt";
case LTE -> "$lte";
case GT -> "$gt";
case GTE -> "$gte";
case NIN -> "$nin";
case IN -> "$in";
default -> throw new UnsupportedOperationException("Not supported expression type: " + exp);
};
}
@Override
public Document convertExpression(Filter.Expression expression) {
String operationType = getOperationSymbol(expression.type());
switch (expression.type()) {
case EQ:
case NE:
case GTE:
case GT:
case LTE:
case LT:
return Document.fromMap(Map.of(((Filter.Key) expression.left()).key(), Document
.fromMap(Map.of(operationType, wrapValue(Objects.requireNonNull(expression.right()))))));
case IN:
case NIN:View on GitHub (pinned to 98a7beda4f)
Solutions
- Rewrite the filter using only supported operators: EQ, NE, LT, LTE, GT, GTE, IN, NIN, AND, OR, NOT.
- Emulate unsupported semantics: replace ISNULL/ISNOTNULL with NE/EQ against null or a sentinel metadata field.
- Check your Spring AI version and upgrade, since newer releases expand the supported operator set.
- If the type is legitimately needed, implement a custom S3VectorFilterExpressionConverter and register it with the S3VectorStore builder.
Example fix
// before
new Filter.Expression(Filter.ExpressionType.ISNULL, new Filter.Key("notes"), null)
// after
new Filter.Expression(Filter.ExpressionType.EQ, new Filter.Key("notes"), new Filter.Value(null)) Defensive patterns
Strategy: validation
Validate before calling
private static final Set<Filter.ExpressionType> SUPPORTED = Set.of(AND, NOT, OR, EQ, NE, LT, LTE, GT, GTE, NIN, IN);
if (!SUPPORTED.contains(expr.type())) throw new IllegalArgumentException("Unsupported for S3: " + expr.type()); Try / catch
try { store.similaritySearch(req); } catch (UnsupportedOperationException e) { log.warn("Filter uses unsupported operator: {}", e.getMessage()); } Prevention
- Restrict filter builders to the 11 supported ExpressionTypes when targeting S3 Vectors.
- Centralize filter construction in one helper so unsupported operators are caught early.
- Re-check supported operators when bumping Spring AI versions.
When it happens
Trigger: Calling S3VectorStore similaritySearch with a SearchRequest filter expression whose Filter.ExpressionType is not in the switch (e.g. ISNULL/ISNOTNULL, or an enum constant from a newer Spring AI release), which reaches getOperationSymbol via convertExpression.
Common situations: Upgrading Spring AI and using new filter operators against the S3 vector store before converter support was added; hand-constructing Filter.Expression objects with exotic types; copying filters built for another store (e.g. PgVector) that supports more operators.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unsupported operator:
- Not supported expression type:
- Unsupported Number type:
- Unsupported operand type:
- Expression of type %s requires a left operand
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/e1985d9c9fa57445.
Report an issue: GitHub.