8
n8n 中文网amn8n.com

我的工作流

高级

这是一个Engineering领域的自动化工作流,包含 19 个节点。主要使用 If, Set, Code, Airtable, HttpRequest 等节点。 使用Airtable分页将Pinecone索引迁移至Weaviate类

前置要求
  • Airtable API Key
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "70nCcZ6MOikosz1s",
  "meta": {
    "instanceId": "6ad1373397d514eb10e9e3e3c99f6b7224997beefed92cec2f1c6706e8ff4b78"
  },
  "name": "我的工作流",
  "tags": [],
  "nodes": [
    {
      "id": "9dea6e2b-c029-480c-96a6-d274b8fcb835",
      "name": "参数设置",
      "type": "n8n-nodes-base.set",
      "position": [
        1168,
        176
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "abbf5e04-4ba0-4178-8bbd-acba3ce456a8",
              "name": "sourceIndex",
              "type": "string",
              "value": "https://<your_pinecone_source_index>"
            },
            {
              "id": "3fc450b0-1d66-4c03-80c4-b20751d5fede",
              "name": "sourceNamespace",
              "type": "string",
              "value": "<your_pinecone_namespace>"
            },
            {
              "id": "493093cb-ab83-4a8d-88ad-3c6064b5a877",
              "name": "batchLimit",
              "type": "string",
              "value": "100"
            },
            {
              "id": "8d916161-130f-47d1-bffe-c6c62c13affd",
              "name": "targetCollection",
              "type": "string",
              "value": "<your_weaviate_target_collection>"
            },
            {
              "id": "3fd34e4b-fe97-4c3d-835f-a6f40d02c104",
              "name": "weaviateCluster",
              "type": "string",
              "value": "https://<your_weaviate_cluster_REST>"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "d2bf3d80-dc9a-4f10-9046-ad053472a551",
      "name": "获取下一页令牌",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1392,
        176
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "app4dxOyxKbkYOFfL",
          "cachedResultUrl": "https://airtable.com/app4dxOyxKbkYOFfL",
          "cachedResultName": "Cycle"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblIBrPDIVMwtUMJr",
          "cachedResultUrl": "https://airtable.com/app4dxOyxKbkYOFfL/tblIBrPDIVMwtUMJr",
          "cachedResultName": "NextPage"
        },
        "options": {},
        "operation": "search",
        "returnAll": false,
        "filterByFormula": "{Number} = 0 "
      },
      "executeOnce": true,
      "typeVersion": 2.1
    },
    {
      "id": "1da994c9-ff3d-40dd-89c4-cb1cb0cd2b6a",
      "name": "迁移完成",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1936,
        576
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "68919d6c-8cc7-4475-8be0-6260edf5199b",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 784,
        "height": 464,
        "content": "## 用于将索引从Pinecone传输到Weaviate的工具"
      },
      "typeVersion": 1
    },
    {
      "id": "18bb5baa-0054-40bd-97ba-578516c0b602",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        976,
        176
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "seconds",
              "secondsInterval": 15
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b0be1637-f09a-4798-a83a-d2c37f0b8a04",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1888,
        64
      ],
      "parameters": {
        "width": 2176,
        "height": 432,
        "content": "## 迭代"
      },
      "typeVersion": 1
    },
    {
      "id": "bb45d339-53dd-4abb-8e2b-9340d8d3220c",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1888,
        528
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 256,
        "content": "## 迁移完成"
      },
      "typeVersion": 1
    },
    {
      "id": "499564f0-4434-481a-9339-72e88b30eb7c",
      "name": "保存下一页令牌",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2688,
        144
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "app4dxOyxKbkYOFfL",
          "cachedResultUrl": "https://airtable.com/app4dxOyxKbkYOFfL",
          "cachedResultName": "Cycle"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblIBrPDIVMwtUMJr",
          "cachedResultUrl": "https://airtable.com/app4dxOyxKbkYOFfL/tblIBrPDIVMwtUMJr",
          "cachedResultName": "NextPage"
        },
        "columns": {
          "value": {
            "Name": "={{ $json.pagination.next ?? ''}} ",
            "Number": "=0"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "upsert"
      },
      "executeOnce": true,
      "typeVersion": 2.1
    },
    {
      "id": "bcbd68d4-9c07-491d-ad8e-a67ae2381488",
      "name": "准备获取正文",
      "type": "n8n-nodes-base.code",
      "position": [
        3136,
        144
      ],
      "parameters": {
        "jsCode": "// Gestisci sia array che singoli oggetti\nlet input = $input.first().json;\n\n// Debug iniziale\nconsole.log(\"Input raw:\", JSON.stringify(input, null, 2));\n\n// Se l'input è un array, prendi il primo elemento\nif (Array.isArray(input)) {\n  console.log(\"Input è un array, prendo il primo elemento\");\n  input = input[0];\n}\n\n// Verifica che vectors esista ed è un array\nif (!input.vectors || !Array.isArray(input.vectors)) {\n  console.error(\"Struttura input:\", {\n    hasVectors: input.hasOwnProperty('vectors'),\n    vectorsType: typeof input.vectors,\n    keys: Object.keys(input)\n  });\n  throw new Error(`Il campo 'vectors' è mancante o non è un array. Input ricevuto: ${JSON.stringify(input, null, 2)}`);\n}\n\n// Verifica che ci siano vettori\nif (input.vectors.length === 0) {\n  throw new Error(\"L'array 'vectors' è vuoto.\");\n}\n\n// Estrai gli ID\nconst ids = input.vectors.map(vector => vector.id);\n\n// Restituisci l'oggetto per il fetch\nreturn [{\n  ids: ids,\n  namespace: input.namespace || \"jira\",\n}];\n\n\n\n\n\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "3223964e-0677-4b19-8062-73656690f678",
      "name": "获取向量",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3360,
        144
      ],
      "parameters": {
        "url": "={{ $('Parameters').item.json.sourceIndex }}/vectors/fetch",
        "options": {
          "response": {
            "response": {}
          }
        },
        "jsonBody": "={\n  \"ids\": {{ JSON.stringify($json.ids) }},\n  \"namespace\": \"{{ $json.namespace }}\",\n  \"include_values\": true,\n  \"include_metadata\": true\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "pineconeApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "771a089c-f40e-48d1-8cd4-b5b1fa86f673",
      "name": "格式化为Weaviate",
      "type": "n8n-nodes-base.code",
      "position": [
        3568,
        144
      ],
      "parameters": {
        "jsCode": "const vectors = items[0].json.vectors;\nconst targetClass = $('Parameters').first().json.targetCollection\n\nreturn Object.entries(vectors).map(([key, vectorObj]) => {\n  const { id, values, metadata } = vectorObj;\n\n  return {\n    json: {\n      class: targetClass,\n      id: id,\n      vector: values,\n      properties: {\n        issue_customer: metadata.issue_customer,\n        issue_id: metadata.issue_id,\n        issue_key: metadata.issue_key,\n        summary: metadata.summary,\n        text: metadata.text,\n        triage: metadata.triage\n      }\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "b2e15a06-9fef-4b9f-a6fe-e91bb7cfbef7",
      "name": "加载到Weaviate",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3776,
        144
      ],
      "parameters": {
        "url": "=https://{{ $('Parameters').item.json.weaviateCluster }}/v1/objects",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ $json}}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "80926411-9cc2-4c66-9545-e2da375718f1",
      "name": "第一次迭代?",
      "type": "n8n-nodes-base.if",
      "position": [
        1952,
        160
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bc83b99c-17d5-4530-8e2a-6400681aa388",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Name.trim() }}",
              "rightValue": "INIT"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b0df747c-4e63-4234-a93a-45423a1c126e",
      "name": "获取第一页记录",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2336,
        144
      ],
      "parameters": {
        "url": "={{ $('Parameters').item.json.sourceIndex }}/vectors/list",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "namespace",
              "value": "={{ $('Parameters').last().json.sourceNamespace }}"
            },
            {
              "name": "limit",
              "value": "={{ $('Parameters').item.json.batchLimit }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "pineconeApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "8161d3c2-8154-471b-a966-0d8a1b037d5e",
      "name": "获取下一页记录",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2336,
        320
      ],
      "parameters": {
        "url": "={{ $('Parameters').item.json.sourceIndex }}/vectors/list",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "namespace",
              "value": "={{ $('Parameters').last().json.sourceNamespace }}"
            },
            {
              "name": "limit",
              "value": "={{ $('Parameters').item.json.batchLimit }}"
            },
            {
              "name": "pagination_token",
              "value": "={{ $json.Name.trim() }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "pineconeApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "d97df28a-cb8b-40f5-b942-43357d0ab127",
      "name": "选择ID",
      "type": "n8n-nodes-base.set",
      "position": [
        2928,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "dbafca81-5ccb-441c-ab6f-3dbf193c8bb6",
              "name": "vectors",
              "type": "array",
              "value": "={{ $('Get Record First Page').item.json.vectors }}"
            },
            {
              "id": "4b2a121c-3afe-42c9-950b-70bef453644d",
              "name": "namespace",
              "type": "string",
              "value": "={{ $('Get Record First Page').item.json.namespace }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "22b96d41-2557-4b8c-a2eb-08696cd786d4",
      "name": "选择ID1",
      "type": "n8n-nodes-base.set",
      "position": [
        2928,
        320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "dbafca81-5ccb-441c-ab6f-3dbf193c8bb6",
              "name": "vectors",
              "type": "array",
              "value": "={{ $('Get Record Next Page').item.json.vectors }}"
            },
            {
              "id": "4b2a121c-3afe-42c9-950b-70bef453644d",
              "name": "namespace",
              "type": "string",
              "value": "={{ $('Get Record Next Page').item.json.namespace }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "88b3ec21-dd1d-4743-a3bb-fc9fa66a6562",
      "name": "保存下一页令牌1",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2688,
        320
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "app4dxOyxKbkYOFfL",
          "cachedResultUrl": "https://airtable.com/app4dxOyxKbkYOFfL",
          "cachedResultName": "Cycle"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblIBrPDIVMwtUMJr",
          "cachedResultUrl": "https://airtable.com/app4dxOyxKbkYOFfL/tblIBrPDIVMwtUMJr",
          "cachedResultName": "NextPage"
        },
        "columns": {
          "value": {
            "Name": "={{ $json.pagination.next ?? ''}} ",
            "Number": "=0"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "upsert"
      },
      "executeOnce": true,
      "typeVersion": 2.1
    },
    {
      "id": "f95c699a-89fb-4a28-b35f-ed9c4485fed2",
      "name": "下一页分页令牌是否为null?",
      "type": "n8n-nodes-base.if",
      "position": [
        1600,
        176
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6a5dea40-2fdc-4b8e-8771-aded6ff36d59",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.Name.trim().length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3f97a527-5f68-42f1-abe7-7211ee7f32b8",
  "connections": {
    "Parameters": {
      "main": [
        [
          {
            "node": "Get Next Page Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Ids": {
      "main": [
        [
          {
            "node": "Prepare Fetch Body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Ids1": {
      "main": [
        [
          {
            "node": "Prepare Fetch Body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Vectors": {
      "main": [
        [
          {
            "node": "Format2Weaviate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format2Weaviate": {
      "main": [
        [
          {
            "node": "LoadWeAviate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "First Iteration?": {
      "main": [
        [
          {
            "node": "Get Record First Page",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Record Next Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Fetch Body": {
      "main": [
        [
          {
            "node": "Fetch Vectors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Next Page Token": {
      "main": [
        [
          {
            "node": "Is Next Pagination Token null?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Record Next Page": {
      "main": [
        [
          {
            "node": "Save Next Page Token1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Next Page Token": {
      "main": [
        [
          {
            "node": "Select Ids",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Record First Page": {
      "main": [
        [
          {
            "node": "Save Next Page Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Next Page Token1": {
      "main": [
        [
          {
            "node": "Select Ids1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Next Pagination Token null?": {
      "main": [
        [
          {
            "node": "First Iteration?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Migration completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 工程

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量19
分类1
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者

Experienced and professional manager with over 20 years of experience in consulting for business process digitalization, driven by a strong passion for organization.

外部链接
在 n8n.io 查看

分享此工作流