Upsert Vector
在向量数据库中插入或更新记录。
实验性。将 index 和 vectors 发送到后端尚不存在的向量写入端点,因此目前不会存储任何内容;调用失败后本次运行也随之失败。
用于数据摄取阶段。它接收向量(及其元数据/文本),并存入索引以供后续检索。
适用场景:
- 为新文档建立索引。
- 更新用户画像的嵌入。
工作原理
- 解析节点配置:配置键中的表达式会基于本次运行求值;传入条目按原样使用。
- 将传入条目与配置合并,并要求提供
index和非空的vectors数组;缺少任一项都会抛出异常。 - 向后端 POST
{ index, vectors }。404 会以Upsert service not available on Backend抛出。 - 如果后端成功响应,worker 会返回不含
port的{ __port: "success", count };引擎会路由到此节点未声明的out,因此success连线不会执行。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-vector-upsert",
"label": "Store embeddings",
"operator_slug": "ai.vector.upsert",
"operator_version": "1.0.0",
"config": {
"index": "handbook"
}
}{
"ok": true,
"port": "out",
"data": {
"__port": "success",
"count": 2
}
}配置
-
indexstring 必填
配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
vectors - 从传入条目读取(或从配置中的
vectors键读取,可为表达式)。每条记录为{ id, values, metadata };按原样发送,不做校验。
输出端口
success 默认 永远不会触发:即使调用成功也会路由到未声明的 out。代码将返回的结构如下:
{
"__port": "success",
"count": 2
}error 从不以信封形式返回:所有失败都会抛出异常并使运行失败。
在表达式中
后续节点可通过 $("Upsert Vector").item.json.<路径> 读取此节点输出中的内容(请把 Upsert Vector 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 success 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Upsert Vector").item.json.count执行 UPSERT 的记录数。 | ||
$("Upsert Vector").item.json.__port | — |
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
Missing 'index' config. Set a target index in the node configuration. | error | 以异常抛出,而不是作为信封返回:引擎会将本次运行标记为失败,除非节点位于 flow.try 作用域内,此时错误会进入其 catch 分支。 |
Missing or empty 'vectors' input. Provide at least one vector record. | error | 以异常抛出,而不是作为信封返回:引擎会将本次运行标记为失败,除非节点位于 flow.try 作用域内,此时错误会进入其 catch 分支。 |
Upsert service not available on Backend | error | 后端尚未提供向量写入端点(HTTP 404)。以异常抛出:除非被 flow.try 作用域捕获,否则运行失败。 |
输入契约
-
vectorsarray<object> 必填 -
要插入的记录列表。
输出契约
-
countnumber 可选 -
执行 UPSERT 的记录数。
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "ai.vector.upsert",
"name": "Upsert Vector",
"category": "ai",
"version": "1.0.0",
"description": "Inserts or Updates records in a Vector Database.\n\n Used during the ingestion phase. It takes vectors (and their metadata/text) and stores them in the index for future retrieval.\n\n **Use Cases:**\n - Indexing a new document.\n - Updating user profile embeddings.",
"capabilities": [
"vector",
"database",
"write",
"upsert"
],
"config_schema": {
"type": "object",
"required": [
"index"
],
"properties": {
"index": {
"type": "string",
"title": "Target Index"
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
},
"input_contract_schema": {
"type": "object",
"properties": {
"vectors": {
"type": "array",
"description": "List of records to insert.",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "number"
}
},
"metadata": {
"type": "object"
}
}
}
}
},
"required": [
"vectors"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"count": {
"type": "number",
"description": "Number of records UPSERTED."
}
}
},
"ports": [
{
"port_id": "success",
"label": "Success",
"is_default": true
},
{
"port_id": "error",
"label": "Error"
}
],
"execution_mode": "async",
"tags": [
"vector",
"write",
"database"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"required": [
"index"
],
"properties": {
"index": {
"type": "string",
"title": "Target Index"
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
}{
"type": "object",
"properties": {
"vectors": {
"type": "array",
"description": "List of records to insert.",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "number"
}
},
"metadata": {
"type": "object"
}
}
}
}
},
"required": [
"vectors"
]
}{
"type": "object",
"properties": {
"count": {
"type": "number",
"description": "Number of records UPSERTED."
}
}
}[
{
"port_id": "success",
"label": "Success",
"is_default": true
},
{
"port_id": "error",
"label": "Error"
}
]执行
- 执行方式
async- 有状态
- 否
- 重试(
retryOnFail) - 否
- 能力
vectordatabasewriteupsert- 标签
vectorwritedatabase
说明与限制
- 后端尚未实现:没有可写入的向量存储。请勿在生产工作流中使用此节点。
- 后端请求未设置超时。
已对照编排器代码核实 · 31e874b · 2026-11-26