CreateCollection 用于创建一个新的数据集 Collection。创建成功后,可以写入数据。
说明
字段名 | 类型 | 是否必传 | 说明 |
---|---|---|---|
CollectionName |
| 是 | 数据集名称 |
Description |
| 否 | 数据集描述 |
CollectionAliases |
| 否 | 数据集别名列表 |
Fields |
| 是 | 数据集字段 |
type FieldInfo =
| ScalarFieldInfo
| PrimaryKeyFieldInfo
| DenseVectorFieldInfo
| SparseVectorFieldInfo
| TextFieldInfo
enum FieldType {
Int64 = "int64",
Float32 = "float32",
String = "string",
Boolean = "bool",
ListString = "list<string>",
ListInt64 = "list<int64>",
/** 稠密向量 */
DenseVector = "vector",
/** 稀疏向量 */
SparseVector = "sparse_vector",
Text = "text",
}
type PipelineName =
| "text_split_bge_large_zh"
| "text_bge_large_zh"
| "text_split_bge_m3"
| "text_bge_m3"
| "text_split_bge_large_and_m3"
| "text_bge_large_and_m3"
字段名 | 类型 | 是否必传 | 说明 |
---|---|---|---|
FieldName |
| 是 | 字段名 |
FieldType |
| 是 | 字段类型 |
DefaultValue |
| 否 | 字段默认值,类型需要与传入的 FieldType 对齐 |
字段名 | 类型 | 是否必传 | 说明 |
---|---|---|---|
FieldName |
| 是 | 字段名 |
FieldType |
| 是 | 字段类型 |
IsPrimary |
| 是 | 是否主键字段,只允许传 |
字段名 | 类型 | 是否必传 | 说明 |
---|---|---|---|
FieldName |
| 是 | 字段名 |
FieldType |
| 是 | 字段类型 |
Dim |
| 是 | 向量维度,需要 4 的倍数 |
字段名 | 类型 | 是否必传 | 说明 |
---|---|---|---|
FieldName |
| 是 | 字段名 |
FieldType |
| 是 | 字段类型 |
字段名 | 类型 | 是否必传 | 说明 |
---|---|---|---|
FieldName |
| 是 | 字段名 |
FieldType |
| 是 | 字段类型 |
PipelineName |
| 否 | 绑定的 pipeline_name |
declare class VikingdbResponse {
readonly OriginalRequest: string;
readonly LogId: string;
constructor(
OriginalRequest: string,
LogId: string
);
}
import { vikingdb } from '@volcengine/openapi'
declare const service: vikingdb.VikingdbService // 替换为你初始化好的实例
await service.collection.CreateCollection({
CollectionName: 'test_collection_1',
Description: 'collection_description', // optional
CollectionAliases: ['collection_alias_1', 'collection_alias_2'], // optional
Fields: [
{ FieldName: 'Id', FieldType: vikingdb.FieldType.Int64, IsPrimary: true }, // 主键字段
{ FieldName: 'Name', FieldType: vikingdb.FieldType.String, DefaultValue: 'Hello world'/* optional */ }, // 标量字段
{ FieldName: 'DenseVector', FieldType: vikingdb.FieldType.DenseVector, Dim: 4 }, // 稠密向量字段
{ FieldName: 'SparseVector', FieldType: vikingdb.FieldType.SparseVector }, // 稀疏向量字段
{ FieldName: 'Text', FieldType: vikingdb.FieldType.Text, PipelineName: 'text_bge_m3', /* optional */ }, // 文本字段
]
})