{"record":{"id":"493f3100a8a469a7","repo":"spring-projects/spring-ai","slug":"not-supported-expression-type-expressiontype-493f31","errorCode":null,"errorMessage":"Not supported expression type: {expressionType}","messagePattern":"Not supported expression type: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-elasticsearch-store/src/main/java/org/springframework/ai/vectorstore/elasticsearch/ElasticsearchAiSearchFilterExpressionConverter.java","lineNumber":97,"sourceCode":"\t}\n\n\t@Override\n\tprotected void doAddValueRangeSpitter(Filter.Value listValue, StringBuilder context) {\n\t\tcontext.append(\" OR \");\n\t}\n\n\tprivate String getOperationSymbol(Expression exp) {\n\t\treturn switch (exp.type()) {\n\t\t\tcase AND -> \" AND \";\n\t\t\tcase OR -> \" OR \";\n\t\t\tcase EQ, IN -> \"\";\n\t\t\tcase NE -> \" NOT \";\n\t\t\tcase LT -> \"<\";\n\t\t\tcase LTE -> \"<=\";\n\t\t\tcase GT -> \">\";\n\t\t\tcase GTE -> \">=\";\n\t\t\tcase NIN -> \"NOT \";\n\t\t\tdefault -> throw new RuntimeException(\"Not supported expression type: \" + exp.type());\n\t\t};\n\t}\n\n\t@Override\n\tpublic void doKey(Key key, StringBuilder context) {\n\t\tvar fieldPath = \"metadata.\" + key.key().trim();\n\t\temitLuceneString(fieldPath, context);\n\t\tcontext.append(':');\n\t}\n\n\t@Override\n\tprotected void doValue(Filter.Value filterValue, StringBuilder context) {\n\t\tif (filterValue.value() instanceof List list) {\n\t\t\tint c = 0;\n\t\t\tfor (Object v : list) {\n\t\t\t\tthis.doSingleValue(normalizeDateString(v), context);\n\t\t\t\tif (c++ < list.size() - 1) {\n\t\t\t\t\tthis.doAddValueRangeSpitter(filterValue, context);","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-elasticsearch-store/src/main/java/org/springframework/ai/vectorstore/elasticsearch/ElasticsearchAiSearchFilterExpressionConverter.java#L79-L115","documentation":"ElasticsearchAiSearchFilterExpressionConverter.getOperationSymbol throws RuntimeException when it encounters a Filter.Expression type it has no SQL-like operator mapping for. Only IN, EQ, NE, LT, LTE, GT, GTE, NIN are supported; grouping with AND/OR is handled elsewhere, so anything else (unsupported future types) hits the default branch.","triggerScenarios":"Passing a Filter.Expression whose ExpressionType is not in the supported set (e.g. an unsupported/extension type) into vectorStore.delete(Filter.Expression) or similaritySearch with a filter that gets converted to Elasticsearch query-string syntax.","commonSituations":"Building custom expression types, using a newer Spring AI Filter API with an older converter, or programmatically constructing expressions with types the converter never learned to serialize.","solutions":["Restrict filter expressions to IN, EQ, NE, LT, LTE, GT, GTE, NIN and AND/OR grouping","Upgrade spring-ai-elasticsearch-store so converter and Filter API versions match","Extend the converter by subclassing and overriding getOperationSymbol if a custom type is required"],"exampleFix":"// before: unsupported custom expression type\nExpression expr = new Filter.Expression(MyCustomType.MATCHES, key, value);\n// after: use supported types\nExpression expr = new Filter.Expression(ExpressionType.EQ, key, value);","handlingStrategy":"validation","validationCode":"private static final Set<ExpressionType> SUPPORTED = Set.of(IN, EQ, NE, LT, LTE, GT, GTE, NIN);\nvoid validate(Filter.Expression e) { if (!SUPPORTED.contains(e.type())) throw new IllegalArgumentException(\"Unsupported type: \" + e.type()); }","typeGuard":null,"tryCatchPattern":"try {\n    vectorStore.delete(filterExpression);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Not supported expression type\")) {\n        throw new IllegalArgumentException(\"Simplify the filter to supported operators\", e);\n    }\n    throw e;\n}","preventionTips":["Only build filters with IN, EQ, NE, LT, LTE, GT, GTE, NIN and AND/OR","Keep Spring AI core and store module versions aligned","Unit-test custom converters against all ExpressionType values"],"tags":["elasticsearch","filter-expression","vector-store","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}