{"record":{"id":"58fae8fe3bb0c051","repo":"spring-projects/spring-ai","slug":"document-id-management-is-disabled-delete-operati","errorCode":null,"errorMessage":"Document ID management is disabled. Delete operations may not work as expected since document IDs are auto-generated by OpenSearch. Consider using filter-based deletion instead.","messagePattern":"Document ID management is disabled\\. Delete operations may not work as expected since document IDs are auto-generated by OpenSearch\\. Consider using filter-based deletion instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"vector-stores/spring-ai-opensearch-store/src/main/java/org/springframework/ai/vectorstore/opensearch/OpenSearchVectorStore.java","lineNumber":253,"sourceCode":"\t\t\t\t\tObjects.requireNonNullElse(document.getText(), \"\"), document.getMetadata(), embedding.get(i));\n\n\t\t\t// Conditionally set document ID based on manageDocumentIds flag\n\t\t\tif (this.manageDocumentIds) {\n\t\t\t\tbulkRequestBuilder.operations(op -> op\n\t\t\t\t\t.index(idx -> idx.index(this.index).id(openSearchDocument.id()).document(openSearchDocument)));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbulkRequestBuilder\n\t\t\t\t\t.operations(op -> op.index(idx -> idx.index(this.index).document(openSearchDocument)));\n\t\t\t}\n\t\t}\n\t\tbulkRequest(bulkRequestBuilder.build());\n\t}\n\n\t@Override\n\tpublic void doDelete(List<String> idList) {\n\t\tif (!this.manageDocumentIds) {\n\t\t\tlogger.warn(\"Document ID management is disabled. Delete operations may not work as expected \"\n\t\t\t\t\t+ \"since document IDs are auto-generated by OpenSearch. Consider using filter-based deletion instead.\");\n\t\t}\n\n\t\tBulkRequest.Builder bulkRequestBuilder = new BulkRequest.Builder();\n\t\tfor (String id : idList) {\n\t\t\tbulkRequestBuilder.operations(op -> op.delete(idx -> idx.index(this.index).id(id)));\n\t\t}\n\t\tif (bulkRequest(bulkRequestBuilder.build()).errors()) {\n\t\t\tthrow new IllegalStateException(\"Delete operation failed\");\n\t\t}\n\t}\n\n\tprivate BulkResponse bulkRequest(BulkRequest bulkRequest) {\n\t\ttry {\n\t\t\treturn this.openSearchClient.bulk(bulkRequest);\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new RuntimeException(e);","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-opensearch-store/src/main/java/org/springframework/ai/vectorstore/opensearch/OpenSearchVectorStore.java#L235-L271","documentation":"OpenSearchVectorStore.doDelete warns when manageDocumentIds is disabled. In that mode document ids are auto-generated by OpenSearch at index time, so the store cannot map Spring AI Document ids to OpenSearch _id values and delete-by-id may remove nothing or the wrong documents. Filter-based deletion is the supported alternative.","triggerScenarios":"Calling vectorStore.delete(List.of(id)) on a store built without document id management enabled (OpenSearchVectorStore.builder(...).withManageDocumentIds(true) not set).","commonSituations":"Default builder configuration where add() documents were stored with OpenSearch-generated ids; upgrading from a setup that never managed ids; mixed writes from other tools that bypass the store's id mapping.","solutions":["Enable id management: OpenSearchVectorStore.builder(embeddingModel, openSearchClient).withManageDocumentIds(true).build()","Use delete(FilterExpression) (filter-based deletion) instead of delete-by-id when id management is off","Re-index existing documents through the store with id management enabled so ids are recorded","Suppress/ignore the warning if you only ever delete via filters"],"exampleFix":"// before\nOpenSearchVectorStore store = OpenSearchVectorStore.builder(embeddingModel, client).build();\n\n// after\nOpenSearchVectorStore store = OpenSearchVectorStore.builder(embeddingModel, client)\n    .withManageDocumentIds(true)\n    .build();","handlingStrategy":"validation","validationCode":"// ensure id management is on before relying on delete-by-id\nif (!isManageDocumentIdsEnabled(store)) {\n    throw new IllegalStateException(\"Use delete(FilterExpression) or enable withManageDocumentIds(true)\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable withManageDocumentIds(true) at build time","Prefer filter-based deletes when ids are OpenSearch-generated","Index documents only through the store so id mapping stays consistent","Re-index once after enabling id management"],"tags":["opensearch","delete","document-id","configuration"],"backgroundTag":"feature-not-enabled","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"}