vdb/README.md
2026-02-06 15:08:27 +08:00

209 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# vdb
## 安装
执行
```
git clone https://git.opencomputing.cn/yumoqing/vdb.git
cd vdb
bash ./build.sh
```
执行完成后:
1 添加了一个vdb.service 重启后会自动启动向量数据库服务
2 使用sudo systemctl XXX vdb.service开启动停止 重启服务
3 app/vdbapp.py 正在执行
## 字段类型
以下字段类型可用在集合的话数据类型中
* "str": 可变长字符串, 需要max_length属性
* "int": 整数类型
* "bool": 逻辑值类型
* "float": 浮点数
* "fvector": 浮点数向量,常规向量都用此类型,
* "bvector": 二进制向量 二分向量使用,
* "json": json格式的数据
一些例子
```
[
# 1. 主键字段 (必选): str 类型非自增手动指定ID以便与业务系统关联
{
"name": "id",
"type": "str",
"max_length": 32
"is_primary": True,
"auto_id": False
},
# 2. 向量字段 (核心): 存储 CLIP 提取的特征768 维
{
"name": "video_embedding",
"type": "fvector",
"dim": 768
},
# 3. 变长字符串: 存储视频存储路径,需指定最大长度
{
"name": "file_path",
"type": "str",
"max_length": 512
},
# 4. 浮点数: 存储评估得分 (如 VBench 的综合分数)
{
"name": "quality_score",
"type": "float"
},
# 5. 布尔值: 标记是否已完成人工复核
{
"name": "is_reviewed",
"type": "bool"
},
# 6. 整数: 存储视频的时长(秒)
{
"name": "duration_sec",
"type": "int"
},
# 7. JSON 字段: 存储非结构化的元数据(如 VBench 的 16 个子维度细节)
# Milvus 2.4+ 支持 JSON 动态解析查询
{
"name": "meta_data",
"type": "json"
}
]
```
## API
对外提供http的接口安全要求会提供客户端ip过滤
### 创建集合
path/v1/createcollection
methodPOST
headers{
"Content-Type": "application/json"
}
data{
colname: 集合名字,必须提供
fields: 集合字段集,请参照字段类型提供
description:可选, 集合描述
}
成功返回
{
"status":"SUCCEEDED"
}
失败返回
{
"status":"FAILED",
"error": 错误信息
}
### 删除集合
path/v1/dropcollection
methodPOST
headers{
"Content-Type": "application/json"
}
data{
colname: 集合名字,必须提供
}
成功返回
{
"status":"SUCCEEDED"
}
失败返回
{
"status":"FAILED",
"error": 错误信息
}
### 向集合插入一到多条记录
path/v1/upsert
methodPOST
headers{
"Content-Type": "application/json"
}
data{
colname: 集合名字,必须提供
data: 数据字典或数据字典数组
}
成功返回
{
"status":"SUCCEEDED"
}
失败返回
{
"status":"FAILED",
"error": 错误信息
}
### 删除集合一到多条记录
path/v1/delete
methodPOST
headers{
"Content-Type": "application/json"
}
data{
colname: 集合名字,必须提供
pks: 主键或主键数组
description:可选, 集合描述
}
成功返回
{
"status":"SUCCEEDED"
}
失败返回
{
"status":"FAILED",
"error": 错误信息
}
### 查询集合数据
path/v1/createcollection
methodPOST
headers{
"Content-Type": "application/json"
}
data{
colname: 集合名字,必须提供
fields: 集合字段集,请参照字段类型提供
description:可选, 集合描述
}
成功返回
{
"status":"SUCCEEDED"
"data": 返回数据
}
失败返回
{
"status":"FAILED",
"error": 错误信息
}
返回数据有如下结构
{
"total": -1, # 不知道总共多少条符合条件的数据
"page": 当前页起始1
"pagerows": 每页记录数
"rows": 记录数据
}