{"record":{"id":"fb005e272f199bed","repo":"spring-projects/spring-ai","slug":"deleted-only-deletecount-entries-from-requested","errorCode":null,"errorMessage":"Deleted only ${deleteCount} entries from requested ${idList.size()}","messagePattern":"Deleted only (.+?) entries from requested (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStore.java","lineNumber":321,"sourceCode":"\t\t// used by MilvusFilterExpressionConverter so quotes, backslashes and control\n\t\t// chars cannot break out of the string literal and inject filter syntax.\n\t\tString deleteExpression = String.format(\"%s in [%s]\", this.idFieldName,\n\t\t\t\tidList.stream()\n\t\t\t\t\t.map(MilvusFilterExpressionConverter::toFilterExpressionLiteral)\n\t\t\t\t\t.collect(Collectors.joining(\",\")));\n\n\t\tDeleteParam.Builder deleteParamBuilder = DeleteParam.newBuilder()\n\t\t\t.withDatabaseName(this.databaseName)\n\t\t\t.withCollectionName(this.collectionName)\n\t\t\t.withExpr(deleteExpression);\n\t\tif (StringUtils.hasText(this.partitionName)) {\n\t\t\tdeleteParamBuilder.withPartitionName(this.partitionName);\n\t\t}\n\t\tR<MutationResult> status = this.milvusClient.delete(deleteParamBuilder.build());\n\n\t\tlong deleteCount = status.getData().getDeleteCnt();\n\t\tif (logger.isWarnEnabled() && deleteCount != idList.size()) {\n\t\t\tlogger.warn(\"Deleted only \" + deleteCount + \" entries from requested \" + idList.size());\n\t\t}\n\t}\n\n\t@Override\n\tprotected void doDelete(Filter.Expression filterExpression) {\n\t\tAssert.notNull(filterExpression, \"Filter expression must not be null\");\n\n\t\ttry {\n\t\t\tString nativeFilterExpression = this.filterExpressionConverter.convertExpression(filterExpression);\n\n\t\t\tDeleteParam.Builder deleteParamBuilder = DeleteParam.newBuilder()\n\t\t\t\t.withDatabaseName(this.databaseName)\n\t\t\t\t.withCollectionName(this.collectionName)\n\t\t\t\t.withExpr(nativeFilterExpression);\n\t\t\tif (StringUtils.hasText(this.partitionName)) {\n\t\t\t\tdeleteParamBuilder.withPartitionName(this.partitionName);\n\t\t\t}\n\t\t\tR<MutationResult> status = this.milvusClient.delete(deleteParamBuilder.build());","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStore.java#L303-L339","documentation":"MilvusVectorStore.doDelete compares the deleteCnt returned by the Milvus server's delete MutationResult with the number of requested ids and warns when fewer entries were actually deleted. Some requested document ids did not exist (or did not match) in the collection/partition, so the delete was partial.","triggerScenarios":"vectorStore.delete(List.of(id1, id2, ...)) where one or more ids are absent from the collection, were already deleted, or were written to a different partition than this.partitionName.","commonSituations":"Deleting documents that were added with a different MilvusVectorStore configuration (different collection/partition); stale ids from an external registry; re-running an idempotency retry that already deleted the docs; ids changed because idFieldName/custom id mapping differs.","solutions":["Verify each id exists before deleting (query by primary key) or tolerate partial deletes as normal","Check that the partitionName configuration matches the partition where the documents were inserted","Ensure documents were inserted through the same store/collection (same collectionName and id field) you are deleting from","If deletes must be exact, wrap the operation and reconcile ids whose deletion count differs"],"exampleFix":"// before\nvectorStore.delete(ids); // may silently delete fewer\n\n// after\nlong existing = ids.stream().filter(id -> vectorStore.getById(id) != null).count();\nvectorStore.delete(ids);\nlogger.info(\"requested \" + ids.size() + \", expected deletable \" + existing);","handlingStrategy":"validation","validationCode":"// verify ids exist before delete to interpret partial results\nSet<String> existing = ids.stream()\n    .filter(id -> milvusVectorStore.getById(id) != null)\n    .collect(Collectors.toSet());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Expect partial deletes when ids may be absent — treat as informational","Keep partitionName consistent between insert and delete paths","Use one store instance/config for the full document lifecycle","Watch WARN logs 'Deleted only N entries' to detect id drift"],"tags":["milvus","delete","partial-delete","vector-store"],"backgroundTag":"empty-result-set","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}