IBM Cloud Docs
Connecting to Milvus service

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 and port information from Infrastructure manager (click the Milvus service to open the Details page and note the host and port 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: