Hi I can’t update array to Pqsql. Can someone know what happen?
Describe the problem/error/question
I confirm that my column in database is vector store size 3072 as same as input size
What is the error message (if any)?
this is my error:
Hi I can’t update array to Pqsql. Can someone know what happen?
I confirm that my column in database is vector store size 3072 as same as input size
this is my error:
Your column type is vector(3072) (probably from pgvector extension).
n8n is passing the embedding as a JavaScript array ([0.01347, -0.02049, …]).
Postgres vector type does not accept JSON arrays directly.
It expects either:
A string representation in curly braces (for arrays), e.g. ‘{0.01347,-0.02049,…}’
Or for vector, a space-delimited list inside single quotes: ‘0.01347 -0.02049 -0.01517 …’
Solution is: Convert to space-delimited string for vector
IN your function code, transform the array
const input = items[0].json;
const arr = input.embedding;
// pgvector expects: ‘0.01347 -0.02049 -0.01517 …’
input.embedding_str = arr.join(" ");
return [{ json: input }];
Then in Update rows in table, map embedding to {{ $json.embedding_str }} instead of {{ $json.embedding }}.
Thank you for your help!!
I have try to pass embedding_str but it still invalid input.
command that I have tried:
embedding_str = " ".join(map(str, values))
embedding_str = “[” + “,”.join(str(v) for v in values) + “]”
I confirm that my embedding column in database is vector type.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.