Schema 结构
字段类型须预先声明,写入不会自动新增字段或修改 Schema。
{"primary_key": "id","fields": {"id": {"type": "string"},"title": {"type": "text", "full_text_search": {"stemming": true}},"price": {"type": "float64"},"tags": {"type": "[]string"},"embedding": {"type": "vector","dimension": 4,"distance_metric": "cosine"}}}
节点名称 | 类型 | 必选 | 描述 |
primary_key | string | 否 | 主键字段名,须在 fields 中定义;省略时使用系统 _id |
fields | object | 否 | 字段定义映射,未配置 primary_key 时可省略或为空。默认最多100个用户字段,其中 vector 最多 4 个、text 最多 10 个,不受索引开关影响。自动 _id 不计数,用户主键计数;以有效配额为准,字段顺序不保证。 |
字段名仅支持英文字母、数字和下划线,不能以数字开头,长度 1~63 字节;
_id 规则见主键模式。主键模式
用户主键模式不额外生成
_id,可将其定义为普通字段;系统主键模式禁止声明 _id。字段定义
type 必填,其余配置须适用于该类型;可选项 null 视为省略,未知项会被拒绝。非主键字段可为空,不支持 nullable 配置。配置项 | 类型 | 适用字段类型 | 描述 |
type | string | 全部 | 字段类型,必填 |
filterable | bool | 标量(不含 bytes)、标量数组、json | 是否支持过滤,默认 true |
dimension | uint32 | vector | 向量维度,必填,1 - 4096 |
data_type | string | vector | 元素类型,默认 float32;支持 float32、float16、bfloat16、int8 |
distance_metric | string | vector | 必填,支持 cosine、l2、dot_product |
ann | bool | vector | 默认 true;false 时仅存储,不支持检索 |
full_text_search | object | text | 全文索引配置 |
字段类型
类型 | 描述 |
bool | 布尔值 |
int8、int16、int32、int64 | 有符号整数 |
uint64 | 无符号整数 |
float32、float64、bfloat16 | 浮点数 |
datetime | Unix 毫秒,接受整数毫秒(数值或字符串)、ISO 日期或日期时间。无时区按 UTC,日期按 UTC 零点解释。例如 "2026-11-16T12:00:00+08:00"。 |
string | 字符串,支持整串匹配 |
bytes | 标准 Base64 字符串(非 URL-safe,末尾 = 可省略),不接受数值数组。 |
json | 任意 JSON 值 |
[]bool、[]int8、[]int16、[]int32、[]int64、[]uint64、[]float32、[]float64、[]datetime、[]string | 标量数组,允许空数组及 null 元素,元素按对应类型校验; [] 不等于字段为 null。 |
text | 全文检索文本 |
vector | 数值数组须与 dimension 等长,不含 null;int8 为 -128 至127的整数,浮点转换后须为有限值。 也支持原始字节的标准 Base64(非 JSON 文本),按小端序编码。字节长度为维度乘以元素字节数:float32 为4,float16/bfloat16 为2,int8 为1。 |
过滤索引
filterable 控制字段是否支持过滤,默认 true。适用类型见字段定义表。全文索引配置
仅用于 text,值为对象;省略或
{} 表示启用,{"enabled": false} 关闭。配置项 | 类型 | 描述 |
enabled | bool | 启用全文索引,默认 true;false 时不能设置分析器选项 |
tokenizer | string | simple(默认):按非字母数字分隔;whitespace:按空白分隔;raw:整串为一个 token,忽略其余分析器选项,保留原值 |
language | string | 分析语言,默认 english;支持 arabic、danish、dutch、english、finnish、french、german、greek、hungarian、italian、norwegian、portuguese、romanian、russian、spanish、swedish、tamil 和 turkish。 |
stemming | bool | 词干提取,默认 false,按 language 处理;不能与 case_sensitive 同时为 true(raw 除外) |
stopwords | bool | 停用词过滤,默认 false;非 raw 下,arabic、greek、romanian、tamil、turkish 不支持启用 |
case_sensitive | bool | 默认 false;为 false 时转小写(raw 除外) |
ascii_folding | bool | ASCII 折叠,默认 false,如 é→e |