From ce21392a21383527366f350f002c2b7c4ffb7119 Mon Sep 17 00:00:00 2001 From: YHW Date: Tue, 16 Jan 2024 04:25:23 +0900 Subject: [PATCH] community: add a flag that determines whether to load the milvus collection (#15693) fix https://github.com/langchain-ai/langchain/issues/15694 --------- Co-authored-by: hyungwookyang Co-authored-by: Bagatur --- .../langchain_community/vectorstores/milvus.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/milvus.py b/libs/community/langchain_community/vectorstores/milvus.py index 4c626edce8..ed751271e0 100644 --- a/libs/community/langchain_community/vectorstores/milvus.py +++ b/libs/community/langchain_community/vectorstores/milvus.py @@ -446,9 +446,15 @@ class Milvus(VectorStore): timeout: Optional[float] = None, ) -> None: """Load the collection if available.""" - from pymilvus import Collection - - if isinstance(self.col, Collection) and self._get_index() is not None: + from pymilvus import Collection, utility + from pymilvus.client.types import LoadState + + if ( + isinstance(self.col, Collection) + and self._get_index() is not None + and utility.load_state(self.collection_name, using=self.alias) + == LoadState.NotLoad + ): self.col.load( partition_names=partition_names, replica_number=replica_number,