spring-projects/spring-ai · error · RuntimeException

Not supported expression type: {expressionType}

Error message

Not supported expression type: {expressionType}

What it means

MariaDBFilterExpressionConverter.getOperationSymbol maps Filter.ExpressionType values to SQL operator strings for MariaDB vector search WHERE clauses. If doExpression encounters an expression type not covered by the switch (e.g. NOT is grouped only with NIN, and types like AND/OR are handled elsewhere but an unhandled type slips through), it throws this RuntimeException. It means the filter expression used a comparison operator the MariaDB converter does not support.

Source

Thrown at vector-stores/spring-ai-mariadb-store/src/main/java/org/springframework/ai/vectorstore/mariadb/MariaDBFilterExpressionConverter.java:144

		}

		context.append("'"); // Closing quote
	}

	private String getOperationSymbol(Expression exp) {
		return switch (exp.type()) {
			case AND -> " AND ";
			case OR -> " OR ";
			case EQ -> " = ";
			case NE -> " != ";
			case LT -> " < ";
			case LTE -> " <= ";
			case GT -> " > ";
			case GTE -> " >= ";
			case IN -> " IN ";
			case NOT, NIN -> " NOT IN ";
			// you never know what the future might bring
			default -> throw new RuntimeException("Not supported expression type: " + exp.type());
		};
	}

	@Override
	protected void doKey(Key key, StringBuilder context) {
		// metadataFieldName could contain a malicious character and hence we treat it as
		// a MariaDB SQL identifier.
		context.append("JSON_VALUE(").append(quoteIdentifier(this.metadataFieldName)).append(", ");

		StringBuilder jsonKey = new StringBuilder();
		emitJsonValue(key.key(), jsonKey);
		// Now, the whole JSONPath is emitted as a SQL string
		emitSqlString("$." + jsonKey.toString(), context);
		context.append(")");
	}

	/**
	 * Quote a SQL identifier using backticks (MySQL/MariaDB standard). Identifiers

View on GitHub (pinned to 98a7beda4f)

Solutions

  1. Rewrite the filter expression using only supported operators: EQ, NE, LT, LTE, GT, GTE, IN, NOT IN.
  2. Replace NOT(group) with an equivalent expression using supported operators where possible.
  3. Check the spring-ai version and upgrade the MariaDB store module to match the core version so new expression types are supported.
  4. Add a case to getOperationSymbol if you maintain a fork.

Example fix

// before
FilterExpression f = new FilterExpressionBuilder().not(
    new FilterExpressionBuilder().eq("genre", "news")).build();
// after
FilterExpression f = new FilterExpressionBuilder().ne("genre", "news").build();
Defensive patterns

Strategy: validation

Validate before calling

private static final Set<Filter.ExpressionType> SUPPORTED = Set.of(EQ, NE, LT, LTE, GT, GTE, IN, NIN, AND, OR);
void assertSupported(Filter.Expression e) {
    if (!SUPPORTED.contains(e.type()))
        throw new IllegalArgumentException("Unsupported for MariaDB: " + e.type());
}

Try / catch

try {
    vectorStore.similaritySearch(request);
} catch (RuntimeException e) {
    if (e.getMessage().startsWith("Not supported expression type")) {
        // fall back to an unfiltered search or rewrite the filter
    }
}

Prevention

When it happens

Trigger: Passing a SearchRequest with a FilterExpression built with an expression type not in the switch (e.g. using NOT/NIN semantics incorrectly, or a newly added expression type from a newer spring-ai core version) to MariaDBVectorStore.similaritySearch.

Common situations: Upgrading spring-ai core introduces new Filter.ExpressionType values the MariaDB converter doesn't handle yet; building filters programmatically with unsupported operators; typos in custom filter DSL usage.

Related errors


AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11). Data as JSON: /api/errors/23569ec01f33d877. Report an issue: GitHub.