diff --git a/integrations/chroma/src/chroma_haystack/document_store.py b/integrations/chroma/src/chroma_haystack/document_store.py index 8af78f05f..ad4777856 100644 --- a/integrations/chroma/src/chroma_haystack/document_store.py +++ b/integrations/chroma/src/chroma_haystack/document_store.py @@ -41,7 +41,7 @@ def __init__( self._embedding_function_params = embedding_function_params # Create the client instance self._chroma_client = chromadb.Client() - self._collection = self._chroma_client.create_collection( + self._collection = self._chroma_client.get_or_create_collection( name=collection_name, embedding_function=get_embedding_function(embedding_function, **embedding_function_params), ) diff --git a/integrations/chroma/tests/test_document_store.py b/integrations/chroma/tests/test_document_store.py index e99a2bbfd..90761f2e5 100644 --- a/integrations/chroma/tests/test_document_store.py +++ b/integrations/chroma/tests/test_document_store.py @@ -112,6 +112,11 @@ def test_from_json(self): assert ds._embedding_function == function_name assert ds._embedding_function_params == {"api_key": "1234567890"} + @pytest.mark.integration + def test_same_collection_name_reinitialization(self): + ChromaDocumentStore("test_name") + ChromaDocumentStore("test_name") + @pytest.mark.skip(reason="Filter on array contents is not supported.") @pytest.mark.unit def test_filter_document_array(self, document_store: ChromaDocumentStore, filterable_docs: List[Document]):