Connecting to Milvus service
Run any one of the following commands to connect with Milvus:
Before you begin
Make sure that the following items are installed or available:
- Python and Pymilvus package. For more information, see About PyMilvus.
- Hostname and port for the Milvus instance. You can get Milvus
host
andport
information from Infrastructure manager (click the Milvus service to open the Details page and note thehost
andport
information from the GRPC host). - Authorized user credentials to access the Milvus instance.
- Assign a role to the user or service ID from Infrastructure manager. For more information about user roles, see Managing roles and privileges.
By using API key
print(fmt.format("start connecting to Milvus"))
connections.connect(host="<host>", port="<port>", secure=True, server_name="localhost", user="ibmlhapikey", password="<api-key>")
has = utility.has_collection("hello_milvus")
print(f"Does collection hello_milvus exist in Milvus: {has}")
By using Token
connections.connect(host="<host>", port="<port>", secure=True, server_name="localhost", user="ibmlhtoken", password="<token>")
For more information about getting a token, see Getting IBM Access Management (IAM) token.
By using URI
This is an alternate method of connecting to Milvus without using the host
and port
parameters.
print(fmt.format("start connecting to Milvus"))
connections.connect( alias="default", uri="https://<host>:<grpc-port>", user = "ibmlhtoken", password = "token" )
has = utility.has_collection("hello_milvus")
print(f"Does collection hello_milvus exist in Milvus: {has}")
For getting API keys, see Getting the IBM API key.
What to do next
You can perform the following operations after establishing a connection with a Milvus service:
- Manage databases: A Milvus cluster supports a maximum of 64 databases. For more information, see Manage Databases.
- Manage collections: A Milvus cluster supports a maximum of 65,536 collections. For more information, see Manage Collections.
- Manage partitions: A Milvus cluster supports a maximum of 4095 partitions. For more information, see Manage Partitions.
- Manage data: For more information, see:
- Manage indexes: For more information, see Manage Indexes.
- Search and Query: For more information, see Search, Query & Get.