{"record":{"id":"70c9c42ce5bd39ff","repo":"spring-projects/spring-ai","slug":"failed-to-delete-documents-by-filter-70c9c4","errorCode":null,"errorMessage":"Failed to delete documents by filter","messagePattern":"Failed to delete documents by filter","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-redis-store/src/main/java/org/springframework/ai/vectorstore/redis/RedisVectorStore.java","lineNumber":453,"sourceCode":"\n\t\t\t\t\tif (errResponse.isPresent()) {\n\t\t\t\t\t\tif (logger.isErrorEnabled()) {\n\t\t\t\t\t\t\tlogger.error(\"Could not delete document: \" + errResponse.get());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new IllegalStateException(\"Failed to delete some documents\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tdeletedCount += docs.size();\n\t\t\t}\n\n\t\t\tif (logger.isDebugEnabled()) {\n\t\t\t\tlogger.debug(\"Deleted \" + deletedCount + \" documents matching filter expression\");\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tlogger.error(\"Failed to delete documents by filter\", e);\n\t\t\tthrow new IllegalStateException(\"Failed to delete documents by filter\", e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<Document> doSimilaritySearch(SearchRequest request) {\n\n\t\tAssert.isTrue(request.getTopK() > 0, \"The number of documents to be returned must be greater than zero\");\n\t\tAssert.isTrue(request.getSimilarityThreshold() >= 0 && request.getSimilarityThreshold() <= 1,\n\t\t\t\t\"The similarity score is bounded between 0 and 1; least to most similar respectively.\");\n\n\t\t// For the IP metric we need to adjust the threshold\n\t\tfinal float effectiveThreshold;\n\t\tif (this.distanceMetric == DistanceMetric.IP) {\n\t\t\t// For IP metric, temporarily disable threshold filtering\n\t\t\teffectiveThreshold = 0.0f;\n\t\t}\n\t\telse {\n\t\t\teffectiveThreshold = (float) request.getSimilarityThreshold();","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-redis-store/src/main/java/org/springframework/ai/vectorstore/redis/RedisVectorStore.java#L435-L471","documentation":"When deleting documents by a FilterExpression, RedisVectorStore.doDelete() wraps the whole FT.SEARCH-and-delete operation in a try/catch and rethrows any Exception as IllegalStateException 'Failed to delete documents by filter' with the original cause attached. It indicates the filter-based delete failed at some stage: query execution, result parsing, or the deletion commands themselves.","triggerScenarios":"Calling vectorStore.delete(filterExpression) with a malformed filter, an index that does not exist, a field name not present in the index schema, or a Redis connection that breaks mid-operation.","commonSituations":"Filter referencing a metadata field not indexed (wrong name or type); Redis index dropped/recreated while deleting; network/timeout issues to Redis; query syntax errors produced by an unsupported filter expression.","solutions":["Inspect the wrapped cause exception (getCause()) for the underlying Redis error","Confirm the index exists and the filter references indexed fields with correct names/types","Validate the filter expression against the metadata schema before deleting","Check Redis connectivity and timeouts; retry once connectivity is restored"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate the filter references indexed fields\nMap<String,Object> info = jedisClient.ftInfo(indexName); // confirm field names/types before delete-by-filter","typeGuard":null,"tryCatchPattern":"try { store.delete(filterExpr); } catch (IllegalStateException e) { log.error(\"Filter delete failed\", e.getCause()); }","preventionTips":["Only filter on indexed metadata fields with correct names/types","Ensure the index exists before delete-by-filter","Handle transient Redis failures with retry/backoff"],"tags":["redis","vector-store","delete","filter","query-failure"],"backgroundTag":"database-query-failed","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"}