{"record":{"id":"98c072201c2601af","repo":"spring-projects/spring-ai","slug":"not-supported-expression-type-98c072","errorCode":null,"errorMessage":"Not supported expression type: ","messagePattern":"Not supported expression type: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-opensearch-store/src/main/java/org/springframework/ai/vectorstore/opensearch/OpenSearchAiSearchFilterExpressionConverter.java","lineNumber":85,"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 = withMetaPrefix(key.key().trim());\n\t\temitLuceneString(fieldPath, context);\n\t\tcontext.append(':');\n\t}\n\n\tpublic String withMetaPrefix(String identifier) {\n\t\treturn \"metadata.\" + identifier;\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;","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-opensearch-store/src/main/java/org/springframework/ai/vectorstore/opensearch/OpenSearchAiSearchFilterExpressionConverter.java#L67-L103","documentation":"OpenSearchAiSearchFilterExpressionConverter.getOperationSymbol throws a RuntimeException when the Filter.ExpressionType being converted has no OpenSearch query-operator mapping in its switch (default branch). The OpenSearch converter supports a different set of types than other stores, so valid expressions elsewhere can fail here.","triggerScenarios":"Running Neo4jVectorStore-style similaritySearch filters against OpenSearchVectorStore with an ExpressionType not in the switch (e.g. IN is handled via doStartValueRange/doEndValueRange but certain types like NOT-in-some-combination hit default).","commonSituations":"Reusing filter expressions built for another vector store (PgVector, Neo4j) with OpenSearch; Spring AI version mismatch adding new ExpressionType values; programmatic filter building with unsupported nodes.","solutions":["Restrict filter expressions to types supported by the OpenSearch converter (AND, OR, EQ, NE, LT, LTE, GT, GTE, NIN, IN via range handling).","Inspect the converter source for the exact supported set in your Spring AI version.","Align Spring AI versions so Filter.ExpressionType and the converter match.","Add the missing case to getOperationSymbol if the type should be supported."],"exampleFix":"// before\nFilter.not(Filter.in(\"status\", List.of(\"x\"))) // NOT may hit the default branch\n// after\nFilter.nin(\"status\", List.of(\"x\")); // directly supported as \"NOT \"","handlingStrategy":"validation","validationCode":"static boolean openSearchSupported(Filter.Expression exp) {\n    return switch (exp.type()) {\n        case AND, OR, EQ, NE, LT, LTE, GT, GTE, IN, NIN -> true;\n        default -> false;\n    };\n}","typeGuard":null,"tryCatchPattern":"try {\n    openSearchStore.similaritySearch(request);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Not supported expression type\")) {\n        // rewrite or drop the filter, then post-filter in memory\n    }\n}","preventionTips":["Do not reuse filter expressions across different vector store backends","Verify converter-supported types for the OpenSearch converter in your version","Keep Spring AI versions aligned across services","Prefer Filter.nin over NOT(In(...)) for OpenSearch"],"tags":["opensearch","filter-expression","unsupported-operation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}