Environment
- milvus-haystack: 0.0.18
- pymilvus: 2.6.11
- Python: 3.12
- Deployment: Docker
Problem
After upgrading pymilvus from 2.5.x to 2.6.x, MilvusDocumentStore fails to initialize. The root cause is that milvus-haystack calls utility.has_collection(using=self.alias), which relies on a connection being registered in the legacy connections module. In pymilvus 2.6.x, MilvusClient.__init__ no longer registers itself in that global registry, so utility cannot find the connection.
Error message
Traceback (most recent call last):
File "/tmp/test_milvus.py", line 3, in
ds = MilvusDocumentStore(
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/milvus_haystack/document_store.py", line 206, in init
if utility.has_collection(self.collection_name, using=self.alias):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pymilvus/orm/utility.py", line 447, in has_collection
return _get_connection(using).has_collection(collection_name, timeout=timeout, context=context)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pymilvus/orm/utility.py", line 175, in _get_connection
return connections._fetch_handler(alias)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pymilvus/orm/connections.py", line 573, in _fetch_handler
raise ConnectionNotExistException(message=ExceptionsMessage.ConnectFirst)
pymilvus.exceptions.ConnectionNotExistException: <ConnectionNotExistException: (code=1, message=should create connection first.)>
Suggested fix
Replace calls to utility.has_collection(using=self.alias) with self._client.has_collection(collection_name) to use the modern MilvusClient API directly, which does not depend on the legacy connection registry.
Workarounds
Pin pymilvus to 2.5.x
Monkey-patch MilvusClient.__init__ to also register with the legacy connections module
Environment
Problem
After upgrading pymilvus from 2.5.x to 2.6.x, MilvusDocumentStore fails to initialize. The root cause is that milvus-haystack calls
utility.has_collection(using=self.alias), which relies on a connection being registered in the legacy connections module. In pymilvus 2.6.x,MilvusClient.__init__no longer registers itself in that global registry, so utility cannot find the connection.Error message
Traceback (most recent call last):
File "/tmp/test_milvus.py", line 3, in
ds = MilvusDocumentStore(
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/milvus_haystack/document_store.py", line 206, in init
if utility.has_collection(self.collection_name, using=self.alias):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pymilvus/orm/utility.py", line 447, in has_collection
return _get_connection(using).has_collection(collection_name, timeout=timeout, context=context)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pymilvus/orm/utility.py", line 175, in _get_connection
return connections._fetch_handler(alias)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pymilvus/orm/connections.py", line 573, in _fetch_handler
raise ConnectionNotExistException(message=ExceptionsMessage.ConnectFirst)
pymilvus.exceptions.ConnectionNotExistException: <ConnectionNotExistException: (code=1, message=should create connection first.)>
Suggested fix
Replace calls to
utility.has_collection(using=self.alias)withself._client.has_collection(collection_name)to use the modern MilvusClient API directly, which does not depend on the legacy connection registry.Workarounds
Pin pymilvus to 2.5.x
Monkey-patch
MilvusClient.__init__to also register with the legacy connections module