Get started with Milvus_CLI

By ChenZhuanghong & Chenzhen on Dec 31, 2021

Get started with Milvus_CLI

In the age of information explosion, we are producing voice, images, videos, and other unstructured data all the time. How do we efficiently analyze this massive amount of data? The emergence of neural networks enables unstructured data to be embedded as vectors, and the Milvus database is a basic data service software, which helps complete the storage, search, and analysis of vector data.

But how can we use the Milvus vector database quickly?

Some users have complained that APIs are hard to memorize and hope there could be simple command lines to operate the Milvus database.

We're thrilled to introduce Milvus_CLI, a command-line tool dedicated to the Milvus vector database.

Milvus_CLI is a convenient database CLI for Milvus, supporting database connection, data import, data export, and vector calculation using interactive commands in shells. The latest version of Milvus_CLI has the following features.

  • All platforms supported, including Windows, Mac, and Linux

  • Online and offline installation with pip supported

  • Portable, can be used anywhere

  • Built on the Milvus SDK for Python

  • Help docs included

  • Auto-complete supported


You can install Milvus_CLI either online or offline.

Install Milvus_CLI online

Run the following command to install Milvus_CLI online with pip. Python 3.8 or later is required.

pip install milvus-cli

Install Milvus_CLI offline

To install Milvus_CLI offline, download the latest tarball from the release page first.

Figure 1. Figure 1.

After the tarball is downloaded, run the following command to install Milvus_CLI.

pip install milvus_cli-<version>.tar.gz

After Milvus_CLI is installed, run milvus_cli. The milvus_cli > prompt that appears indicates that the command line is ready.

Figure 2. Figure 2.

If you're using a Mac with the M1 chip or a PC without a Python environment, you can choose to use a portable application instead. To accomplish this, download a file on the release page corresponding to your OS, run chmod +x on the file to make it executable, and run ./ on the file to run it.


The following example makes milvus_cli-v0.1.8-fix2-macOS executable and runs it.

sudo chmod +x milvus_cli-v0.1.8-fix2-macOS


Connect to Milvus

Before connecting to Milvus, ensure that Milvus is installed on your server. See Install Milvus Standalone or Install Milvus Cluster for more information.

If Milvus is installed on your localhost with the default port, run connect.

Figure 3. Figure 3.

Otherwise, run the following command with the IP address of your Milvus server. The following example uses as the IP address and 19530 as the port number.

connect -h

F F g)

Create a collection

This section introduces how to create a collection.

A collection consists of entities and is similar to a table in RDBMS. See Glossary for more information.

Figure 5. Figure 5.


The following example creates a collection named car. The car collection has four fields which are id, vector, color, and brand. The primary key field is id. See create collection for more information.

create collection -c car -f id:INT64:primary_field -f vector:FLOAT_VECTOR:128 -f color:INT64:color -f brand:INT64:brand -p id -a -d 'car_collection'

List collections

Run the following command to list all collections in this Milvus instance.

list collections

Figure 6. Figure 6.

Run the following command to check the details of the car collection.

describe collection -c car 

Figure 7. Figure 7.

Calculate the distance between two vectors

Run the following command to import data into the car collection.

import -c car ''

Figure 8. Figure 8.

Run query and enter car as the collection name and id>0 as the query expression when prompted. The IDs of the entities that meet the criteria are returned as shown in the following figure.

Figure 9. Figure 9.

Run calc and enter appropriate values when prompted to calculate the distances between vector arrays.

Delete a collection

Run the following command to delete the car collection.

delete collection -c car

Figure 10. Figure 10.


Milvus_CLI is not limited to the preceding functions. Run help to view all commands that Milvus_CLI includes and the respective descriptions. Run <command> --help to view the details of a specified command.

Figure 11. Figure 11.

See also:

Milvus_CLI Command Reference on GitHub

Milvus_CLI Command Reference under Milvus Docs

We hope Milvus_CLI could help you easily use the Milvus vector database. We will keep optimizing Milvus_CLI and your contributions are welcome.

If you have any questions, feel free to file an issue on GitHub.