{"record":{"id":"98c91e3630548aa3","repo":"spring-projects/spring-ai","slug":"failed-to-delete-documents-by-filter-98c91e","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-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant/QdrantVectorStore.java","lineNumber":242,"sourceCode":"\n\t\ttry {\n\t\t\tFilter filter = this.filterExpressionConverter.convertExpression(filterExpression);\n\n\t\t\tio.qdrant.client.grpc.Points.UpdateResult response = this.qdrantClient\n\t\t\t\t.deleteAsync(this.collectionName, filter)\n\t\t\t\t.get();\n\n\t\t\tif (response.getStatus() != io.qdrant.client.grpc.Points.UpdateStatus.Completed) {\n\t\t\t\tthrow new IllegalStateException(\"Failed to delete documents by filter: \" + response.getStatus());\n\t\t\t}\n\n\t\t\tlogger.debug(\"Deleted documents matching filter expression\");\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tif (logger.isErrorEnabled()) {\n\t\t\t\tlogger.error(\"Failed to delete documents by filter: \" + e.getMessage(), e);\n\t\t\t}\n\t\t\tthrow new IllegalStateException(\"Failed to delete documents by filter\", e);\n\t\t}\n\t}\n\n\t/**\n\t * Performs a similarity search on the vector store.\n\t * @param request The {@link SearchRequest} object containing the query and other\n\t * search parameters.\n\t * @return A list of documents that are similar to the query.\n\t */\n\t@Override\n\tpublic List<Document> doSimilaritySearch(SearchRequest request) {\n\t\ttry {\n\t\t\tFilter filter = (request.getFilterExpression() != null)\n\t\t\t\t\t? this.filterExpressionConverter.convertExpression(request.getFilterExpression())\n\t\t\t\t\t: Filter.getDefaultInstance();\n\n\t\t\tfloat[] queryEmbedding = this.embeddingModel.embed(request.getQuery());\n","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant/QdrantVectorStore.java#L224-L260","documentation":"doDelete wraps the whole asynchronous delete-by-filter in a try/catch; any Exception (client errors, connection failures, interrupted/execution exceptions from the future, invalid filter) is logged and rethrown as IllegalStateException 'Failed to delete documents by filter' with the original cause attached. It is the generic failure path for filter-based deletion in QdrantVectorStore.","triggerScenarios":"qdrantClient.deleteAsync(...).get() throwing: connection refused/timeout, gRPC errors (collection not found, permission), or InterruptedException while waiting for the future.","commonSituations":"Wrong collection name or collection deleted; Qdrant unreachable (wrong host/port, network); invalid filter expression producing a server error; client bean misconfigured.","solutions":["Inspect the wrapped cause via e.getCause() to find the underlying gRPC/connection error","Verify Qdrant host/port and connectivity (qdrantClient.listCollections() as smoke test)","Confirm the collection name matches an existing Qdrant collection","Catch IllegalStateException around delete() and retry with backoff for transient network issues"],"exampleFix":"// before\nvectorStore.delete(filterExpression);\n// after\ntry {\n    vectorStore.delete(filterExpression);\n} catch (IllegalStateException e) {\n    logger.error(\"Delete failed: {}\", e.getCause());\n}","handlingStrategy":"try-catch","validationCode":"// smoke test before deletes\nassertDoesNotThrow(() -> qdrantClient.listCollectionsAsync().get());","typeGuard":null,"tryCatchPattern":"try { vectorStore.delete(filterExpr); } catch (IllegalStateException e) { Throwable cause = e.getCause(); logger.error(\"Delete failed due to {}\", cause == null ? e : cause.getMessage()); }","preventionTips":["Log and inspect getCause() for the real gRPC error","Verify Qdrant connectivity and collection existence at startup","Apply exponential backoff retries for transient network failures"],"tags":["qdrant","delete","vector-store","network","spring-ai"],"backgroundTag":"database-write-failed","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"}