🚀 免費嘗試 Zilliz Cloud,完全托管的 Milvus,體驗速度提升 10 倍!立即嘗試

milvus-logo
LFAI
主頁
  • 工具

Milvus_CLI 指令參考

Milvus Command-Line Interface (CLI) 是一個命令列工具,支援資料庫連線、資料操作及資料匯入匯出。

本主題介紹所有支援的命令及相對應的選項。也包括一些範例供您參考。

清除

清除螢幕。

語法

clear

選項

選項全名說明
-help不適用顯示使用指令的說明。

連線

連接至 Milvus。

語法

connect [-uri (text)] [-t (text)]

選項

選項全名說明
-資料來源-uri(可選)uri 名稱。預設為 "http://127.0.0.1:19530"。
-t-token(可選)zilliz 雲端 apikey 或username:password 。預設為無。
-help顯示命令使用說明。

範例

milvus_cli > connect -uri http://127.0.0.1:19530

建立資料庫

在 Milvus 中建立資料庫

語法

create database -db (text)

選項

選項全名說明
-db-資料庫[Required] milvus 中的資料庫名稱。
-help不適用顯示使用指令的說明。

範例

範例一

以下範例在 milvus 中建立資料庫testdb

milvus_cli > create database -db testdb

使用資料庫

在 Milvus 中使用資料庫

語法

use database -db (text)

選項

選項全名說明
-db-資料庫[Required] milvus 中的資料庫名稱。
-help不適用顯示使用指令的說明。

範例

範例一

以下範例使用 milvus 中的資料庫testdb

milvus_cli > use database -db testdb

列出資料庫

列出 Milvus 中的資料庫

語法

list databases

範例

範例 1

以下範例列出 Milvus 中的資料庫。

milvus_cli > list databases

刪除資料庫

刪除 Milvus 中的資料庫

語法

delete database -db (text)

選項

選項全名說明
-db-資料庫[Required] milvus 中的資料庫名稱。
-help不適用顯示使用指令的說明。

範例

範例一

以下範例刪除 milvus 中的資料庫testdb

milvus_cli > delete database -db testdb

建立使用者

在 Milvus 中建立使用者

語法

create user -u (text) -p (text)

選項

選項全名說明
-p-密碼用 milvus 表示的使用者密碼。預設為 「無」。
-u-使用者名稱milvus 中的使用者名稱。預設為 「無」。
-help不適用顯示命令使用說明。

範例

範例一

以下範例在 milvus 中建立使用者zilliz 及密碼zilliz

milvus_cli > create user -u zilliz -p zilliz

建立角色

在 Milvus 中建立角色

語法

create role -r (text)

選項

選項全名說明
-r-角色名稱milvus 角色的角色名稱。
-help不適用顯示使用指令的說明。

範例

範例一

以下範例在 milvus 中建立角色role1

milvus_cli > create role -r role1

建立別名

指定集合的唯一別名。

一個集合可以有多個別名。但是,一個別名最多對應一個集合。

語法

create alias -c (text) -a (text) [-A]

選項

選項全名說明
-c-集合名稱集合的名稱。
-a-別名別名。
-A-alter(可選)將別名轉移至指定集合的旗標。
-help不適用顯示命令使用說明。

範例

範例一

以下範例為car 套件建立carAlias1carAlias2 別名。

milvus_cli > create alias -c car -a carAlias1

範例 2

範例 2 以範例 1 為基礎。

下面的示例將carAlias1 別名從car 集合轉移到car2 集合。

milvus_cli > create alias -c car2 -A -a carAlias1

建立集合

建立一個集合。

語法

create collection -c (text) -f (text) -p (text) [-a] [-d (text)]

選項

選項全名說明
-c-集合名稱集合的名稱。
-f-字段模式(多重)<fieldName>:<dataType>:<dimOfVector/desc> 格式的欄位模式。
-p-schema-主鍵欄位主鍵欄位的名稱。
-a-schema-auto-id。(可選)自動產生 ID 的旗標。
-desc-結構描述(可選)集合的描述。
-等級-一致性等級(可選)一致性等級:Bounded,Session,Strong, Eventual .
-d-是否動態(可選)集合模式是否支援動態欄位。
-s-shards-num(可選擇) 碎片數量
-help不適用顯示使用指令的說明。

範例

## For array field: --schema-field support <fieldName>:<dataType>:<maxCapacity>:<elementDataType>(:<maxLength>if Varchar)

milvus_cli > create collection -c car -f id:INT64:primary_field -f vector:FLOAT_VECTOR:128 -f color:INT64:color -f brand:ARRAY:64:VARCHAR:128 -p id -A -d 'car_collection'

建立分割區

建立分割區。

語法

create partition -c (text) -p (text) [-d (text)]

選項

選項全名說明
-c-集合名稱集合的名稱。
-p-分區分割區名稱。
-d-描述(可選)磁碟分割的描述。
-help不適用顯示使用指令的說明。

範例

milvus_cli > create partition -c car -p new_partition -d test_add_partition

建立索引

為欄位建立索引。

目前,一個集合最多支援一個索引。

語法

create index

選項

選項全名說明
-help不適用顯示命令使用說明。

範例

為欄位建立索引,並提示所需輸入的內容:

milvus_cli > create index

Collection name (car, car2): car2

The name of the field to create an index for (vector): vector

Index name: vectorIndex

# Default is ''
Index type FLAT, IVF_FLAT, IVF_SQ8, IVF_PQ, RNSG, HNSW, ANNOY, AUTOINDEX, DISKANN, GPU_IVF_FLAT, GPU_IVF_PQ, SPARSE_INVERTED_INDEX, SCANN, STL_SORT, Trie, INVERTED, ) []: IVF_FLAT

# Default is ''
Index metric type (L2, IP, HAMMING, TANIMOTO, COSINE, ) []:

Timeout []:

刪除使用者

刪除使用者

語法

delete user -u (text)

選項

選項全名說明
-u-使用者名稱使用者名稱。
-help不適用顯示命令使用說明。

範例

milvus_cli > delete user -u zilliz

刪除角色

刪除 Milvus 中的角色

語法

delete role -r (text)

選項

選項全名說明
-r-角色名稱milvus 角色的角色名稱。
-help不適用顯示使用指令的說明。

範例

以下範例刪除 milvus 中的角色role1

milvus_cli > delete role -r role1

刪除別名

刪除別名。

語法

delete alias -a (text)

選項

選項全名說明
-a-別名別名。
-help不適用顯示使用指令的說明。

刪除集合

刪除一個集合。

語法

delete collection -c (text)

選項

選項全名說明
-c-收藏集名稱要刪除的集合名稱。
-help不適用顯示使用指令的說明。

範例

milvus_cli > delete collection -c car

刪除實體

刪除實體。

語法

delete entities -c (text) -p (text)

選項

選項全名說明
-c-集合名稱要刪除的實體所屬的集合名稱。
-p-分區(可選)要刪除的分割區名稱。
-help不適用顯示使用命令的說明。

範例

milvus_cli > delete entities -c car

The expression to specify entities to be deleted, such as "film_id in [ 0, 1 ]": film_id in [ 0, 1 ]

You are trying to delete the entities of collection. This action cannot be undone!

Do you want to continue? [y/N]: y

刪除分割區

刪除磁碟分割。

語法

delete partition -c (text) -p (text)

選項

選項全名說明
-c-集合名稱要刪除的分割區所屬的集合名稱。
-p-分區要刪除的分割區的名稱。
-help不適用顯示使用命令的說明。

範例

milvus_cli > delete partition -c car -p new_partition

刪除索引

刪除索引及相對應的索引檔案。

目前,一個資料集最多支援一個索引。

語法

delete index -c (text) -in (text)

選項

選項全名說明
-c-集合名稱集合的名稱。
-在-索引名稱索引名稱的名稱。
-help不適用顯示使用指令的說明。

範例

milvus_cli > delete index -c car -in indexName

授予角色

授予使用者角色

語法

選項

選項全名說明
-r-角色名稱milvus 角色的角色名稱。
-u-使用者名稱milvus 使用者的使用者名稱。
-help不適用顯示使用指令的說明。

範例

grant role -r role1 -u user1

授予特權

為角色指定權限。

語法

選項

選項全名說明
-help不適用顯示命令使用說明。

範例

grant privilege

撤銷角色

撤銷指定給使用者的角色。

語法

選項

選項全名說明
-r-角色名稱milvus 角色的角色名稱。
-u-使用者名稱milvus 使用者的使用者名稱。
-help不適用顯示使用指令的說明。

範例

grant role -r role1 -u user1

撤銷權限

撤銷已指定給角色的特權。

語法

選項

選項全名說明
-help不適用顯示命令使用說明。

範例

revoke privilege

顯示集合

顯示集合的詳細資訊。

語法

show collection -c (text)

選項

選項全名說明
-c-集合名稱集合的名稱。
-help不適用顯示使用指令的說明。

範例

milvus_cli > show collection -c test_collection_insert

顯示分割區

顯示分割區的詳細資訊。

語法

show partition -c (text) -p (text)

選項

選項全名說明
-c-集合名稱磁碟分割所屬集合的名稱。
-p-分區分割區的名稱。
-help不適用顯示使用指令的說明。

範例

milvus_cli > show partition -c test_collection_insert -p _default

顯示索引

顯示索引的詳細資訊。

語法

show index -c (text) -in (text)

選項

選項全名說明
-c-集合名稱集合的名稱。
-在-索引名稱索引名稱。

| --help | n/a | 顯示使用指令的說明。|

範例

milvus_cli > show index -c test_collection -in index_name

退出

關閉命令列視窗。

語法

exit

選項

選項全名說明
-help不適用顯示使用指令的說明。

幫助

顯示使用命令的說明。

語法

help <command>

命令

命令說明
清除清除畫面。
連線連線到 Milvus。
建立建立資料集、資料庫、分割區、使用者、角色和索引。
授予授予角色、權限。
撤銷撤銷角色、權限。
刪除刪除資料集、資料庫、分割區、別名、使用者、角色或索引。
退出關閉命令列視窗。
幫助顯示使用命令的說明。
插入將資料匯入分割區。
清單列出集合、資料庫、分割區、使用者、角色、授權或索引。
載入載入集合或分割區。
查詢顯示符合您輸入的所有條件的查詢結果。
釋放釋放集合或分割區。
搜尋執行向量相似性搜尋或混合搜尋。
顯示顯示連線、資料庫、集合、載入進度或索引進度。
重新命名重新命名集合
使用使用資料庫
版本顯示 Milvus_CLI 的版本。

匯入

匯入本機或遠端資料到分割區。

語法

import -c (text)[-p (text)] <file_path>

選項

選項全名說明
-c-集合名稱插入資料的集合名稱。
-p-分區(可選)資料要插入的分割區名稱。未傳入此分割區選項表示選擇「_default」分割區。
-help不適用顯示命令使用說明。

範例一

以下範例匯入一個本機 CSV 檔案。

milvus_cli > import -c car 'examples/import_csv/vectors.csv'

Reading csv file...  [####################################]  100%

Column names are ['vector', 'color', 'brand']

Processed 50001 lines.

Inserting ...

Insert successfully.
--------------------------  ------------------
Total insert entities:                   50000
Total collection entities:              150000
Milvus timestamp:           428849214449254403
--------------------------  ------------------

範例 2

以下範例匯入遠端 CSV 檔案。

milvus_cli > import -c car 'https://raw.githubusercontent.com/milvus-
io/milvus_cli/main/examples/import_csv/vectors.csv'

Reading file from remote URL.

Reading csv file...  [####################################]  100%

Column names are ['vector', 'color', 'brand']

Processed 50001 lines.

Inserting ...

Insert successfully.

--------------------------  ------------------
Total insert entities:                   50000
Total collection entities:              150000
Milvus timestamp:           428849214449254403
--------------------------  ------------------

列出使用者

列出所有使用者。

語法

list users

選項

| 選項 | 全名 | 說明 | | --help | 不適用 | 顯示使用命令的說明。|

列出角色

列出 Milvus 中的角色

語法

list roles

選項

選項全名說明
-help不適用顯示使用指令的說明。

範例

milvus_cli > list roles

列出撥款

列出 Milvus 中的授權

選項

選項全名說明
-r-角色名稱milvus 角色的角色名稱。
-o-物件名稱milvus 物件的物件名稱。
-t-物件類型全局、集合或使用者。
-help不適用顯示使用指令的說明。

範例

milvus_cli > list grants -r role1 -o object1 -t Collection

列出收藏集

列出所有收藏集。

語法

list collections

選項

選項全名說明
-help不適用顯示使用指令的說明。

列出索引

列出集合的所有索引。

目前,一個資料集最多支援一個索引。

語法

list indexes -c (text)

選項

選項全名說明
-c-集合名稱集合的名稱。
-help不適用顯示使用指令的說明。

列出分區

列出集合的所有分區。

語法

list partitions -c (text)

選項

選項全名說明
-c-集合名稱集合的名稱。
-help不適用顯示使用指令的說明。

載入

將資料集或磁碟分割從硬碟空間載入 RAM。

語法

load -c (text) [-p (text)]

選項

選項全名說明
-c-集合名稱磁碟分割所屬集合的名稱。
-p-分區(可選擇/多個)磁碟分割的名稱。
-help不適用顯示使用指令的說明。

查詢

顯示符合您輸入的所有條件的查詢結果。

語法

query

選項

選項全名說明
-help不適用顯示命令使用說明。

範例

範例一

執行查詢,並提示所需輸入的內容:

milvus_cli > query

Collection name: car

The query expression: id in [ 428960801420883491, 428960801420883492,
428960801420883493 ]

Name of partitions that contain entities(split by "," if multiple) []:
default

A list of fields to return(split by "," if multiple) []: color, brand

timeout []:

Guarantee timestamp. This instructs Milvus to see all operations performed before a provided timestamp. If no such timestamp is provided, then Milvus will search all operations performed to date. [0]:
Graceful time. Only used in bounded consistency level. If graceful_time is set, PyMilvus will use current timestamp minus the graceful_time as the guarantee_timestamp. This option is 5s by default if not set. [5]:

範例 2

執行查詢,並提示您輸入所需的內容:

milvus_cli > query

Collection name: car

The query expression: id > 428960801420883491

Name of partitions that contain entities(split by "," if multiple) []:
default

A list of fields to return(split by "," if multiple) []: id, color,
brand

timeout []:

Guarantee timestamp. This instructs Milvus to see all operations performed before a provided timestamp. If no such timestamp is provided, then Milvus will search all operations performed to date. [0]:
Graceful time. Only used in bounded consistency level. If graceful_time is set, PyMilvus will use current timestamp minus the graceful_time as the guarantee_timestamp. This option is 5s by default if not set. [5]:

釋放

從 RAM 釋放資料集或分割區。

語法

release -c (text) [-p (text)]

選項

選項全名說明
-c-集合名稱磁碟分割所屬集合的名稱。
-p-分區(可選擇/多個)磁碟分割的名稱。
-help不適用顯示使用指令的說明。

執行向量相似性搜尋或混合搜尋。

search

選項全名說明
-help不適用顯示使用指令的說明。

在 csv 檔案上執行搜尋,並提示所需的輸入:

milvus_cli > search

Collection name (car, test_collection): car

The vectors of search data(the length of data is number of query (nq), the dim of every vector in data must be equal to vector field’s of collection. You can also import a csv file
out headers): examples/import_csv/search_vectors.csv

The vector field used to search of collection (vector): vector

Search parameter nprobe's value: 10

The max number of returned record, also known as topk: 2

The boolean expression used to filter attribute []: id > 0

The names of partitions to search (split by "," if multiple) ['_default'] []: _default

timeout []:

Guarantee Timestamp(It instructs Milvus to see all operations performed before a provided timestamp. If no such timestamp is provided, then Milvus will search all operations performed to date) [0]:

在已編入索引的資料集中執行搜尋,並提示所需輸入的資料:

milvus_cli > search

Collection name (car, test_collection): car

The vectors of search data(the length of data is number of query (nq), the dim of every vector in data must be equal to vector field’s of collection. You can also import a csv file without headers):
    [[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]]

The vector field used to search of collection (vector): vector

Search parameter nprobe's value: 10

The specified number of decimal places of returned distance [-1]: 5

The max number of returned record, also known as topk: 2

The boolean expression used to filter attribute []: id > 0

The names of partitions to search (split by "," if multiple) ['_default'] []: _default

timeout []:

Guarantee Timestamp(It instructs Milvus to see all operations performed before a provided timestamp. If no such timestamp is provided, then Milvus will search all operations performed to date) [0]:

在非索引的資料集中執行搜尋,並提示所需的輸入:

milvus_cli > search

Collection name (car, car2): car

The vectors of search data(the length of data is number of query (nq), the dim of every vector in data must be equal to vector field’s of collection. You can also import a csv file without headers): examples/import_csv/search_vectors.csv

The vector field used to search of collection (vector): vector

The specified number of decimal places of returned distance [-1]: 5

The max number of returned record, also known as topk: 2

The boolean expression used to filter attribute []:

The names of partitions to search (split by "," if multiple) ['_default'] []:

timeout []:

Guarantee Timestamp(It instructs Milvus to see all operations performed before a provided timestamp. If no such timestamp is provided, then Milvus will search all operations performed to date) [0]:

列出連線

列出連線。

語法

list connections

選項

選項全名說明
-help不適用顯示命令使用說明。

顯示索引進度

顯示實體索引的進度。

語法

show index_progress -c (text) [-i (text)]

選項

選項全名說明
-c-集合名稱實體所屬集合的名稱。
-i-索引(可選)索引的名稱。
-help不適用顯示使用指令的說明。

顯示載入進度

顯示載入資料集的進度。

語法

show loading_progress -c (text) [-p (text)]

選項

選項全名說明
-c-集合名稱實體所屬集合的名稱。
-p-分區(可選擇/多個)載入分割區的名稱。
-help不適用顯示使用指令的說明。

版本

顯示 Milvus_CLI 的版本。

語法

version

選項

選項全名說明
-help不適用顯示使用指令的說明。
您也可以在 shell 中檢查 Milvus_CLI 的版本,如下例所示。在這種情況下,milvus_cli --version 作為命令。

範例

$ milvus_cli --version
Milvus_CLI v0.4.0