跳到主要内容

在本地运行 Milvus Lite

本页面介绍了如何在本地运行 Milvus Lite 以进行开发和测试。

概述

Milvus Lite 是 Milvus 的轻量级版本,Milvus 是一个开源的向量数据库,通过向量嵌入和相似度搜索为 AI 应用提供支持。

Milvus Lite 可以被导入到您的 Python 应用程序中,提供 Milvus 的核心向量搜索功能。Milvus Lite 包含在 Milvus 的 Python SDK 中,因此可以通过 pip install pymilvus 简单部署。该存储库包含了 Milvus Lite 的核心组件。

Milvus Lite 与 Milvus 共享相同的 API,并覆盖了大部分 Milvus 的功能。它们共同为不同规模的环境提供一致的用户体验,适用于不同规模的用例。使用相同的客户端代码,您可以在 Milvus Lite 中快速演示少于百万个向量,或者在单台机器上托管 Milvus Docker 容器的小规模应用程序,最终在 Kubenetes 上进行大规模生产部署,以每秒数千次查询量为服务的数十亿向量。

先决条件

Milvus Lite 支持以下操作系统发行版和芯片类型:

  • Ubuntu >= 20.04 (x86_64)
  • MacOS >= 11.0 (Apple Silicon 和 x86_64)

请注意,Milvus Lite 适用于开始使用向量搜索或构建演示和原型。对于生产用例,我们建议在 DockerKubenetes 上使用 Milvus,或考虑在 Zilliz Cloud 上使用完全托管的 Milvus。

设置 Milvus Lite

Milvus Lite 已经与 pymilvus 打包在一起,pymilvus 是 Milvus 的 Python SDK 库。要设置 Milvus Lite,请在终端中运行以下命令。

pip install "pymilvus>=2.4.2"

连接到 Milvus Lite

您可以按照以下方式连接到 Milvus Lite。

from pymilvus import MilvusClient

client = MilvusClient("milvus_demo.db")

运行上述代码片段后,当前文件夹中将生成一个名为 milvus_demo.db 的数据库文件。

限制

在运行 Milvus Lite 时,请注意某些功能不受支持。以下表格总结了 Milvus Lite 的使用限制。

集合

方法 / 参数Milvus Lite 中的支持情况
create_collection()支持,但参数有限
collection_name
dimension
primary_field_name
id_type
vector_field_name
metric_type
auto_id
schema
index_params
enable_dynamic_field
num_shards
partition_key_field
num_partitions
consistency_level否(仅支持Strong;任何配置都将被视为Strong。)
get_collection_stats()支持获取集合统计信息。
collection_name
timeout
describe_collection()响应中的 num_shardsconsistency_levelcollection_id 无效。
timeout
has_collection()支持检查集合是否存在。
collection_name
timeout
list_collections()支持列出所有集合。
drop_collection()支持删除集合。
collection_name
timeout
rename_collection()不支持重命名集合。

字段与模式

方法 / 参数在 Milvus Lite 中支持
create_schema()支持有限参数
auto_id
enable_dynamic_field
primary_field
partition_key_field
add_field()支持,但参数有限
field_name
datatype
is_primary
max_length
element_type
max_capacity
dim
is_partition_key

插入 & 搜索

方法 / 参数在 Milvus Lite 中支持
search()支持,但参数有限
collection_name
data
filter
limit
output_fields
search_params
timeout
partition_names
anns_field
query()支持有限的参数
collection_name
filter
output_fields
timeout
ids
partition_names
get()支持有限的参数
collection_name
ids
output_fields
timeout
partition_names
delete()支持有限的参数
collection_name
ids
timeout
filter
partition_name

插入 & 更新

方法 / 参数Milvus Lite 中支持的参数
insert()支持有限参数
collection_name
data
timeout
partition_name
upsert()支持有限参数
collection_name
data
timeout
partition_name

载入 & 释放

方法 / 参数Milvus Lite 中支持的参数
load_collection()
collection_name
timeout
release_collection()
collection_name
timeout
get_load_state()不支持获取载入状态。
refresh_load()不支持加载已卸载集合的数据。
close()

索引

方法 / 参数在 Milvus Lite 中支持
list_indexes()支持列出索引。
collection_name
field_name
create_index()仅支持部分索引类型:FLAT, HNSW, BIN_FLAT, SPARSE_INVERTED_INDEX, SPARSE_WAND.
index_params
timeout
drop_index()支持删除索引。
collection_name
index_name
timeout
describe_index()支持描述索引。
collection_name
index_name
timeout

分区

Milvus Lite 不支持分区和与分区相关的方法。

用户 & 角色

Milvus Lite 不支持用户和角色以及相关方法。

别名

Milvus Lite 不支持别名和与别名相关的方法。

其他

对于上表中未列出的其他方法,Milvus Lite 不支持。

下一步

连接到 Milvus Lite 后,您可以: