Hello I am building the workflow to fetch the wordpress site content and it is going to store in vector db so later on I can use that data to feed AI agent.
Describe the problem/error/question
I chunk the data and it is ready for embedding with the help of Hugging Face. Once data is emebedding It return the data in array but I need to append the reponse with the existing metadata object.
What is the error message (if any)?
Please share your workflow
Data Chunk Node:
{
"nodes": [
{
"parameters": {
"jsCode": "function chunkText(text, size = 1200, overlap = 150) {\n const chunks = [];\n let start = 0;\n\n while (start < text.length) {\n const end = Math.min(start + size, text.length);\n const chunk = text.slice(start, end).trim();\n\n if (chunk.length > 0) {\n chunks.push(chunk);\n }\n\n start += size - overlap;\n }\n\n return chunks;\n}\n\n\nconst items = $input.all();\n\nlet output = [];\n\nfor (const item of items) {\n\n const input = item.json;\n\n const text = input.clean_text || '';\n\n if (!text) {\n continue;\n }\n\n const chunks = chunkText(text);\n\n chunks.forEach((chunk, index) => {\n\n output.push({\n json: {\n id: input.id,\n title: input.title,\n slug: input.slug,\n link: input.link,\n modified: input.modified || '',\n source_type: input.source_type || 'page',\n\n chunk_index: index,\n\n chunk_text: chunk,\n\n // Later we will use this for upsert/update\n chunk_hash: `${input.id}-${index}-${chunk.length}`\n }\n });\n\n });\n}\n\nreturn output;"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
832,
0
],
"id": "2984be2c-5f97-4833-8d5e-a0912be70559",
"name": "ChunkText"
}
],
"connections": {
"ChunkText": {
"main": [
[]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "a12d2939883b6ee4645287d26116bd7830ea910b3e2205baee32d9bb5d782014"
}
}
Hugging Face Node:
{
"nodes": [
{
"parameters": {
"method": "POST",
"url": "https://router.huggingface.co/hf-inference/models/BAAI/bge-small-en-v1.5",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer <<API TOKEN>>"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{\n{\n inputs: $json.chunk_text\n}\n}}",
"options": {
"response": {
"response": {
"responseFormat": "json"
}
}
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
992,
-144
],
"id": "2f3d7b70-454c-4e1d-8345-33ef8e3b047c",
"name": "Hugging Face API"
}
],
"connections": {
"Hugging Face API": {
"main": [
[]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "a12d2939883b6ee4645287d26116bd7830ea910b3e2205baee32d9bb5d782014"
}
}
Share the output returned by the last node
Response from Hugging Face Models:
[
-0.03779905289411545,
-0.027235977351665497,
0.04070237651467323,
0.02413654699921608,
-0.04879286512732506,
-0.016459722071886063,
-0.0015258010243996978,
0.07087898999452591,
-0.03721754252910614,
0.019904209300875664,
0.022374162450432777,
-0.05740947648882866,
-0.017154762521386147,
0.04529924318194389,
0.0001327882637269795,
-0.023566097021102905,
0.008483237586915493,
0.013999130576848984,
-0.057878654450178146,
0.0066631208173930645,
0.034953076392412186,
-0.02018037624657154,
-0.013172738254070282,
-0.030672265216708183,
0.007248119916766882
]
Vector db schema:
create table public.site_chunks (
id bigserial not null,
url text not null,
title text null,
chunk_text text not null,
chunk_hash text not null,
source_type text not null,
modified_at timestamp with time zone null,
created_at timestamp with time zone not null default now(),
updated_at timestamp with time zone not null default now(),
embedding public.vector null,
constraint site_chunks_pkey primary key (id)
) TABLESPACE pg_default;
create unique INDEX IF not exists site_chunks_url_hash_idx on public.site_chunks using btree (url, chunk_hash) TABLESPACE pg_default;
create index IF not exists site_chunks_source_type_idx on public.site_chunks using btree (source_type) TABLESPACE pg_default;
create index IF not exists site_chunks_modified_at_idx on public.site_chunks using btree (modified_at) TABLESPACE pg_default;
Note: As I provided single array output but I have 53 chunks text and I am going to embedding and API return the total 20352 items so I am not sure how to map all those data with my existing records.
Sample Input:
[
{
“id”: 1383,
“title”: “blog”,
“url”: “TEST”,
“content”: “”,
“modified”: “2026-07-29T23:06:08”,
“source_type”: “page”,
“clean_text”: “”
},
{
“id”: 1222,
“title”: “Laser Dentistry”,
“slug”: “”,
“link”: “”,
“date”: “”,
“clean_text”: “Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum”
} ]
Note: I am sending clean_text in the body parameter for embedding.
Expected output:
{ "url": "", "title": "Laser Dentistry", "chunk_text": "LASER DENTISTRY...", "chunk_hash": "1222-0-1200", "source_type": "page", "modified_at": null, "embedding": "[-0.037799,-0.027235,0.040702,...]" }
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app): Azure App Service
- Operating system: Linux