Milvus Command Line Interface (CLI)
Milvus Command Line Interface (CLI) is a command line tool that supports database connection, data operations, import, and export of data. Based on the Milvus Python SDK, it allows executing commands via interactive command line prompts through the terminal.
Current Version
The current version of Milvus CLI is 0.4.0. To find the installed version and determine if an update is needed, run the milvus_cli --version
command.
Installing Milvus CLI
Here's how to install Milvus CLI.
Install from PyPI
You can install Milvus CLI from PyPI.
Prerequisites
- Install Python 3.8.5 or a higher version.
- Install pip.
Using pip to Install
Run the following command to install Milvus CLI.
pip install milvus-cli
Install using Docker
You can install Milvus CLI using Docker.
Prerequisites
Docker version 19.03 or higher is required.
Install from Docker Image
$ docker run -it zilliz/milvus_cli:latest
Install from Source Code
- Run the following command to download the
milvus_cli
repository.
git clone https://github.com/zilliztech/milvus_cli.git
- Run the following command to enter the
milvus_cli
folder.
cd milvus_cli
- Run the following command to install Milvus CLI.
python -m pip install --editable .
Alternatively, you can also install Milvus CLI from a compressed tarball (.tar.gz
file). Download the tarball and then run python -m pip install milvus_cli-.tar.gz
.
Install from .exe File
This installation method is only applicable to Windows.
Download a .exe file from GitHub and run it to install Milvus CLI. If successful, a milvus_cli-.exe
will pop up as shown in the image below.
Milvus CLI Command Reference
Here is the list of all supported commands with their corresponding options, including some examples for reference.
clear
Clear the screen content.
Syntax
clear
Options
Option | Full Name | Description |
---|---|---|
--help | N/A | Display help information for using this command. |
connect
Connect to Milvus.
Syntax
connect [-uri (text)] [-t (text)]
Options
Option | Full Name | Description |
---|---|---|
-uri | --uri | (Optional) URI name. Defaults to "http://127.0.0.1:19530". |
-t | --token | (Optional) zilliz cloud apikey or username:password . Defaults to None. |
--help | N/A | Display help information for using this command. |
Example
milvus_cli > connect -uri http://127.0.0.1:19530
create Database
Create a database in Milvus.
Syntax
create database -db (text)
Options
Option | Full Name | Description |
---|---|---|
-db | --database | [Required] The name of the database in Milvus. |
--help | n/a | Display help information for using this command. |
Example
Example 1
The following example creates a database named testdb
in Milvus.
milvus_cli > create database -db testdb
Use Database
Use a database in Milvus.
Syntax
use database -db (text)
Options
Option | Full Name | Description |
---|---|---|
-db | --database | [Required] The name of the database in Milvus. |
--help | n/a | Display help for using the command. |
Example
Example 1
The following example uses a database named testdb
in Milvus.
milvus_cli > use database -db testdb
List Databases
List databases in Milvus.
Syntax
list databases
Example
Example 1
The following example lists the databases in Milvus.
milvus_cli > list databases
Delete Database
Delete a database in Milvus.
Syntax
delete database -db (text)
Options
Option | Full Name | Description |
---|---|---|
-db | --database | [Required] The name of the database in Milvus. |
--help | n/a | Display help for using the command. |
Example
Example 1
The following example deletes a database named testdb
in Milvus.
milvus_cli > delete database -db testdb
Create User
Create a user in Milvus.
Syntax
create user -u (text) -p (text)
Options
Option | Full Name | Description |
---|---|---|
-p | --password | The user's password in Milvus. Default value is "None". |
-u | --username | The username in Milvus. Default value is "None". |
--help | n/a | Display help for using the command. |
Example
Example 1
The following example creates a user with the username zilliz
and password zilliz
in Milvus.
milvus_cli > create user -u zilliz -p zilliz
Create Alias
Assign a unique alias for a collection.
A collection can have multiple aliases, but an alias corresponds to only one collection.
Syntax
create alias -c (text) -a (text) [-A]
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection. |
-a | --alias-name | The alias. |
-A | --alter | (Optional) Flag to transfer an alias to a specified collection. |
--help | n/a | Display help for using the command. |
Example
Example 1
The following example creates aliases carAlias1
and carAlias2
for a collection named car
.
milvus_cli > create alias -c car -a carAlias1
Example 2
Example 2 is based on Example 1.
The following example moves the carAlias1
alias from the car
collection to the car2
collection.
milvus_cli > create alias -c car2 -A -a carAlias1
Create Collection
Create a collection.
Syntax
create collection -c (text) -f (text) -p (text) [-a] [-d (text)]
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | Name of the collection. |
-f | --schema-field | (multiple) Field patterns in the format of :: . |
-p | --schema-primary-field | Name of the primary key field. |
-a | --schema-auto-id | (optional) Flag for auto-generating ID. |
-desc | --schema-description | (optional) Description of the collection. |
-level | --consistency-level | (optional) Consistency level: Bounded, Session, Strong, Eventual. |
-d | --is-dynamic | (optional) Whether the collection schema supports dynamic fields. |
-s | --shards-num | (optional) Number of shards. |
--help | n/a | Display command usage help. |
Example
milvus_cli > 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'
Create Partition
Create a partition.
Syntax
create partition -c (text) -p (text) [-d (text)]
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | Name of the collection. |
-p | --partition | Name of the partition. |
-d | --description | (optional) Description of the partition. |
--help | n/a | Display command usage help. |
Example
milvus_cli > create partition -c car -p new_partition -d test_add_partition
Create Index
Create an index for a field.
Currently, a collection supports a maximum of one index.
Syntax
create index
Options
Option | Full Name | Description |
---|---|---|
--help | n/a | Display command usage help. |
Example
To create an index for a field and prompt for the required information:
milvus_cli > create index
Collection name (car, car2): car2
Field name to create an index for (vector): vector
Index name: vectorIndex
Index type (FLAT, IVF_FLAT, IVF_SQ8, IVF_PQ, RNSG, HNSW, ANNOY, AUTOINDEX, DISKANN, ) []: IVF_FLAT
Index metric type (L2, IP, HAMMING, TANIMOTO,): L2
Index nlist parameter: 2
Timeout []:
Delete User
Delete a user.
Syntax
delete user -u (text)
Options
Option | Full Name | Description |
---|---|---|
-u | --username | Username. |
--help | n/a | Display command usage help. |
Example
milvus_cli > delete user -u zilliz
Delete Alias
Delete an alias.
Syntax
delete alias -a (text)
Options
Option | Full Name | Description |
---|---|---|
-a | --alias-name | Alias. |
--help | n/a | Display command usage help. |
Delete Collection
Delete a collection.
Syntax
delete collection -c (text)
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection to be deleted. |
--help | n/a | Display command usage help. |
Example
milvus_cli > delete collection -c car
Delete Entities
Delete entities.
Syntax
delete entities -c (text) -p (text)
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection to which the entity belongs. |
-p | --partition | (Optional) The name of the partition to be deleted. |
--help | n/a | Display help information on how to use the command. |
Example
milvus_cli > delete entities -c vehicles
Specify the expression for the entities to be deleted, e.g., "movie IDs in [0,1]": movie IDs in [0,1]
You are attempting to delete entities from the collection. This operation cannot be undone!
Continue with this operation? [y/N]: y
Delete Partition
Delete a partition.
Syntax
delete partition -c (text) -p (text)
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection to which the partition belongs. |
-p | --partition | The name of the partition to be deleted. |
--help | n/a | Display help information on how to use the command. |
Example
milvus_cli > delete partition -c vehicles -p new_partition
Delete Index
Delete the index and the corresponding index files.
Currently, a collection supports up to one index.
Syntax
delete index -c (text) -in (text)
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection. |
-in | --index-name | The name of the index. |
--help | n/a | Display help information on how to use the command. |
Example
milvus_cli > delete index -c vehicles -in index_name
Describe Collection
Display detailed information about the collection.
Syntax
show collection -c (text)
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection. |
--help | n/a | Display help information on how to use the command. |
Example
milvus_cli > show collection -c test_collection_insert
Describe Partition
Display detailed information about the partition.
Syntax
show partition -c (text) -p (text)
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection to which the partition belongs. |
-p | --partition | The name of the partition. |
--help | n/a | Display help information on how to use the command. |
milvus_cli > show partition -c test_collection_insert -p _default
Index Description
Display detailed information about the index.
Syntax
show index -c (text) -in (text)
Options
Option | Full name | Description |
---|---|---|
-c | --collection-name | The name of the collection. |
-in | --index-name | The name of the index. |
--help | n/a | Display help information on how to use this command. |
Example
milvus_cli > show index -c test_collection -in index_name
Exit
Close the command line window.
Syntax
exit
Options
Option | Full name | Description |
---|---|---|
--help | n/a | Display help information on how to use this command. |
Help
Display help information for the command.
Syntax
help
Commands
Command | Description |
---|---|
calc | Calculate the distance between two vector arrays, which can be mkts_from_hybridts, mkts_from_unixtime, hybridts_to_unixtime. |
clear | Clear the screen. |
connect | Connect to Milvus. |
create | Create a collection, partition, index, or alias. |
delete | Delete a collection, partition, index, entity, or alias. |
describe | Describe a collection, partition, or index. |
exit | Close the command line window. |
help | Display help information for the command. |
import | Import data into a partition. |
list | List collections, partitions, or indexes. |
load | Load a collection or partition into memory. |
load_balance | Perform load balancing on the query node. |
query | Display query results that satisfy all input conditions. |
release | Release a collection or partition. |
search | Perform vector similarity search or hybrid search. |
show | Display the current collection, entity loading progress, entity indexing progress, or segment information. |
version | Display the version of Milvus_CLI. |
Import
Import local or remote data into a partition.
Syntax
import -c (text)[-p (text)]
Options
Option | Full name | Description |
---|---|---|
-c | --collection-name | The name of the collection where the data will be inserted. |
-p | --partition | (Optional) The name of the partition where the data will be inserted. Omitting this partition option indicates selecting the "_default" partition. |
--help | n/a | Display help information on how to use this command. |
Example 1
The following example imports a local CSV file.
milvus_cli > import -c car 'examples/import_csv/vectors.csv'
Reading csv file... [####################################] 100%
Column names ['vector', 'color', 'brand']
Processed 50001 lines.
Inserting...
Successfully inserted.
-------------------------- ------------------
Total entities inserted: 50000
Total collection entities: 150000
Milvus timestamp: 428849214449254403
-------------------------- ------------------
Example 2
The following example imports a remote CSV file.
milvus_cli > import -c car 'https://raw.githubusercontent.com/milvus-io/milvus_cli/main/examples/import_csv/vectors.csv'
Reading file from a remote URL.
Reading the csv file... [####################################] 100%
Column names are ['vector', 'color', 'brand']
Processing 50001 rows.
Inserting...
Successfully inserted.
-------------------------- ------------------
Total entities inserted: 50000
Total entities in the collection: 150000
Milvus timestamp: 428849214449254403
-------------------------- ------------------
List users
Lists all users.
Syntax
list users
Options
Option | Full name | Description |
---|---|---|
--help | n/a | Displays usage information for this command. |
List collections
Lists all collections.
Syntax
list collections
Options
Option | Full name | Description |
---|---|---|
--help | n/a | Displays usage information for this command. |
List indexes
Lists all indexes for a collection.
Currently, a collection supports at most one index.
Syntax
list indexes -c (text)
Options
Option | Full name | Description |
---|---|---|
-c | --collection-name | The name of the collection. |
--help | n/a | Displays usage information for this command. |
List partitions
Lists all partitions for a collection.
Syntax
list partitions -c (text)
Options
Option | Full name | Description |
---|---|---|
-c | --collection-name | The name of the collection. |
--help | n/a | Displays usage information for this command. |
Load
Loads a collection or partition from disk to memory.
Syntax
load -c (text) [-p (text)]
Options
Option | Full name | Description |
---|---|---|
-c | --collection-name | The name of the collection to which the partition belongs. |
-p | --partition | (Optional/multiple) The name of the partition. |
--help | n/a | Displays usage information for this command. |
Query
Displays query results that match all the conditions you enter.
Syntax
query
Options
Option | Full name | Description |
---|---|---|
--help | n/a | Displays usage information for this command. |
Example
Example 1
Perform a query and prompt for the required information:
milvus_cli > query
Collection name: car
Query expression: id in [428960801420883491, 428960801420883492, 428960801420883493]
Names of partitions containing entities (separated by commas) []: default
List of return fields (separated by commas) []: color, brand
Timeout []:
Guaranteed timestamp. This indicates all operations performed by Milvus before the provided timestamp. If no such timestamp is provided, Milvus will search for all operations performed up to now. [0]: Graceful time. Only used in the bounded consistency level. If graceful_time is set, PyMilvus will subtract the current timestamp from the graceful_time to use as the guaranteed timestamp. If this option is not set, the default value is 5 seconds. [5]:
Example 2
Perform a query and prompt for the required information:
milvus_cli > query
Collection name: car
Query expression: id > 428960801420883491
Names of partitions containing entities (separated by commas) []: default
List of return fields (separated by commas) []: id, color, brand
Timeout []:
Guaranteed timestamp. This indicates all operations performed by Milvus before the provided timestamp. If no such timestamp is provided, Milvus will search for all operations performed up to now. [0]: Graceful time. Only used in the bounded consistency level. If graceful_time is set, PyMilvus will subtract the current timestamp from the graceful_time to use as the guaranteed timestamp. If this option is not set, the default value is 5 seconds. [5]:
Release
Release the RAM of a collection or partition.
Syntax
release -c (text) [-p (text)]
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection to which the partition belongs. |
-p | --partition | (Optional/multiple) The name of the partition. |
--help | n/a | Displays usage information for the command. |
Search
Perform vector similarity search or hybrid search.
Syntax
search
Options
Option | Full Name | Description |
---|---|---|
--help | n/a | Displays usage information for the command. |
Example
Example 1
Perform a search on a csv file and prompt for the required information:
milvus_cli > search
Collection name (car, test_collection): car
Vectors for searching data (the length of data for query (nq), the dimension of each vector in the data must be equal to the vector field of the collection. You can also import a csv file
head): examples/import_csv/search_vectors.csv
Vector field for searching collection (vector): vector
Metric type: L2
Value of nprobe for search parameter: 10
Maximum number of records to return, also known as topk: 2
Boolean expression for filtering properties []: id > 0
Names of partitions to be searched (separated by commas) ['_default'] []: _default
Timeout []:
Guaranteed timestamp (it indicates that Milvus performs all operations before the provided timestamp. If no such timestamp is provided, Milvus will search for all operations up to now) [0]:
Example 2
Perform a search on the index collection and prompt for the required parameters:
milvus_cli > search
Enter the collection name (e.g. car, test_collection): car
Vector data for search (length of the data is the number of query data (nq), the dimension of each vector must be equal to the dimension of vector field in the collection. You can also import a CSV file without a header line):
[[0.71, 0.76, 0.17, 0.13, 0.42, 0.07, 0.15, 0.67, 0.58, 0.02, 0.39, 0.47, 0.58, 0.88, 0.73, 0.31, 0.23, 0.57, 0.33, 0.2, 0.03, 0.43, 0.78, 0.49, 0.17, 0.56, 0.76, 0.54, 0.45, 0.46, 0.05, 0.1, 0.43, 0.63, 0.29, 0.44, 0.65, 0.01, 0.35, 0.46, 0.66, 0.7, 0.88, 0.07, 0.49, 0.92, 0.57, 0.5, 0.16, 0.77, 0.98, 0.1, 0.44, 0.88, 0.82, 0.16, 0.67, 0.63, 0.57, 0.55, 0.95, 0.13, 0.64, 0.43, 0.71, 0.81, 0.43, 0.65, 0.76, 0.7, 0.05, 0.24, 0.03, 0.9, 0.46, 0.28, 0.92, 0.25, 0.97, 0.79, 0.73, 0.97, 0.49, 0.28, 0.64, 0.19, 0.23, 0.51, 0.09, 0.1, 0.53, 0.03, 0.23, 0.94, 0.87, 0.14, 0.42, 0.82, 0.91, 0.11, 0.91, 0.37, 0.26, 0.6, 0.89, 0.6, 0.32, 0.11, 0.98, 0.67, 0.12, 0.66, 0.47, 0.02, 0.15, 0.6, 0.64, 0.57, 0.14, 0.81, 0.75, 0.11, 0.49, 0.78, 0.16, 0.63, 0.57, 0.18]]
Vector field for search (e.g. vector):
Distance measurement type: L2
Value of search parameter nprobe: 10
Number of decimal places for returned distances (also known as topk): 5
Boolean expression for filtering properties ([]): id > 0
Partition names for search (if multiple, separate by commas) ['_default'] []: _default
Timeout ([]):
Timestamp guarantee (tells Milvus to look at all operations performed before the specified timestamp. If no timestamp is provided, Milvus will search all operations performed up to now) [0]:
Example 3
Searching non-indexed collections and prompting for input:
milvus_cli > search
Collection name (car, car2): car
Vectors for searching data (data length for the query count (nq), dimensions for each vector in the data must be equal to the collection's vector field. You can also import a csv file without headers): examples/import_csv/search_vectors.csv
Vector field for searching the collection (vector): vector
Decimal places of returned distances (-1 indicates all places): 5
Maximum number of records returned, also known as topk: 2
Boolean expression for filtering properties: []
Names of partitions to be searched (use ',' to separate if there are multiple): ['_default'] []
Timeout: []
Guaranteed timestamps (it indicates that Milvus views all operations performed before the provided timestamp. If the timestamp is not provided, Milvus will search all operations performed up to now): [0]
List connections
List connections.
Syntax
list connections
Options
Option | Full Name | Description |
---|---|---|
--help | n/a | Display help information for using this command. |
show index_progress
Display the progress of entity indexing.
Syntax
show index_progress -c (text) [-i (text)]
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection to which the entity belongs. |
-i | --index | (Optional) The name of the index. |
--help | n/a | Display help information for using this command. |
show loading_progress
Display the progress of entity loading.
Syntax
show loading_progress -c (text) [-p (text)]
Options
Option | Full Name | Description |
---|---|---|
-c | --collection-name | The name of the collection to which the entity belongs. |
-p | --partition | (Optional/multiple) The name of the partition to be loaded. |
--help | n/a | Display help information for using this command. |
version
Display the version of Milvus_CLI.
Syntax
version
Options
Option | Full Name | Description |
---|---|---|
--help | n/a | Display help information for using this command. |
You can also check the version of Milvus_CLI in the shell, as shown in the following example. In this case, milvus_cli --version
acts as the command.
Example
$ milvus_cli --version
Milvus_CLI v0.4.0