用户之声——提建议·赢好礼> HOT

功能介绍

/ai/collectionView/create 接口用于在已创建的 AI 类 Database 中创建集合视图,用于存储文件数据。

请求示例

注意:
如下示例可直接复制,在运行之前,您需在文本编辑器将 api_key=A5VOgsMpGWJhUI0WmUbY******************** 与 10.0.X.X 依据实际情况进行替换。
如下示例,为 AI 类数据库 db-test-ai,创建一个集合视图 coll-ai-files,用于直接存储文件。
curl -i -X POST \\
-H 'Content-Type: application/json' \\
-H 'Authorization: Bearer account=root&api_key=A5VOgsMpGWJhUI0WmUbY********************' \\
http://10.0.X.X:80/ai/collectionView/create \\
-d '{
"database": "db-test-ai",
"collectionView": "coll-ai-files",
"description": "this is a collection view description",
"embedding": {
"language": "zh",
"enableWordsEmbedding": true
},
"splitterPreprocess": {
"appendTitleToChunk": true,
"appendKeywordsToChunk": true
},
"indexes": [
{
"fieldName": "author",
"fieldType": "string",
"indexType": "filter"
},
{
"fieldName": "tags",
"fieldType": "array",
"indexType": "filter"
}
]
}'

请求参数

参数
参数含义
子参数
是否必选
配置方法
database
指定 CollectionView 所在的 Database 名称。
-
使用/database/list 获取集群中的数据库列表,复制数据库名。
collectionView
指定 CollectionView 的名称。
-
CollectionView 命名要求如下:
只能使用英文字母,数字,下划线_、中划线-,并以英文字母开头。
长度要求:[1,128]。
description
指定 CollectionView 的描述信息
-
取值类型:string。
字符长度要求:[1,256]。
示例:this is the collection view description。
embedding
Embedding相关配置
language
指定文件的语言类型,取值如下所示:
zh:中文。
en:英文。
multi:多语言。
enableWordsEmbedding
配置在检索时,是否开启词(Words)向量精排,并进行词向量化。
true:开启。
false:不开启,默认为 false
splitterPreprocess
文件预处理方式配置
appendTitleToChunk
在对文件拆分时,配置是否将 Title 追加到切分后的段落后面一并 Embedding。取值如下所示:
false:不追加。默认值为 false。
true:将段落 Title 追加到切分后的段落,默认值为 true
appendKeywordsToChunk
在对文件拆分时,配置是否将关键字 keywords 追加到切分后的段落一并 Embedding。取值如下所示:
false:不追加。
true:将全文的 keywords 追加到切分后的段落。默认值为 true。
indexes
配置需使用 Filter 索引的字段,以便检索时使用该字段的 Filter 条件表达式过滤查找文档。


fieldName
自定义配置可作为 Filter 索引的文件 meta 信息的标量字段名。
说明:
Filter 索引(Filter Index)是建立在标量字段的索引。该标量字段名称、类型均由用户自定义,不限制标量字段数量。
标量字段被建立 Filter 索引之后,向量检索时,将依据 Filter 指定的标量字段的条件表达式进行过滤查询和范围查询来匹配相似向量。
建立 Filter 索引时,选取需要使用 Filter 表达式高效过滤数据的标量字段。不做过滤查询、检索的标量字段不必建立 Filter 索引。切勿将所有标量字段建立索引,导致内存资源的浪费。
fieldType
指定自定义字段的数据类型。取值如下:
string:字符型。
uint64:指无符号整数(unsigned integer)。
array:数组类型,数组元素为 string。
indexType
该参数固定设置为 filter。

响应消息

状态码
含义
响应消息
200
集合创建成功
{
"code": 0,
"msg": "operation success",
"affectedCount": 1
}
400
集合创建失败
{
"code": 1,
"msg": "Collection already exist: angular_32",
"affectedCount": 0
}

返回参数

参数名
参数含义
affectedCount
影响行数,即为创建集合数量。