diff --git a/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/vectorstore/ChromaVectorStore.java b/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/vectorstore/ChromaVectorStore.java index a7f9f4782ca..87bd0efcdf5 100644 --- a/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/vectorstore/ChromaVectorStore.java +++ b/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/vectorstore/ChromaVectorStore.java @@ -185,13 +185,16 @@ public String getCollectionId() { @Override public void afterPropertiesSet() throws Exception { - - if (!this.initializeSchema) - return; - var collection = this.chromaApi.getCollection(this.collectionName); if (collection == null) { - collection = this.chromaApi.createCollection(new ChromaApi.CreateCollectionRequest(this.collectionName)); + if (initializeSchema) { + collection = this.chromaApi + .createCollection(new ChromaApi.CreateCollectionRequest(this.collectionName)); + } + else { + throw new RuntimeException("Collection " + this.collectionName + + " doesn't exist. It won't be created when initializeSchema is set to false."); + } } this.collectionId = collection.id(); }