Commands

Upsert

Used to add new vectors or update an existing vector.

You can only upsert vectors with same dimension count(size) as your index.

Arguments

There are two ways to use the upsert method. You can either create the vectors on your own and pass them directly. Or you can pass the data and create the embeddings using Upstash Embedding. The possible payloads are:

VectorPayloadVector | Vector[]required
Namespace{ namespace?: string }

Namespace to upsert to. If not set, default namespace is used.

OR

DataPayloadData | Data[]required
Namespace{ namespace?: string }

Namespace to upsert to. If not set, default namespace is used.

Response

strrequired

'Success' on successful operation.

Single Vector
await index.upsert({  id: "1234",  vector: [0.1, 0.2, 0.3, 0.4, 0.5],  metadata: {    title: "Lord of The Rings",    genre: "drama",    category: "classic",  },});
Multiple Vectors
await index.upsert([  {    id: "6789",    vector: [0.6, 0.7, 0.8, 0.9, 0.9],  },  {    id: "1234",    vector: [0.1, 0.2, 0.3, 0.4, 0.5],    metadata: {      title: "Lord of The Rings",      genre: "drama",      category: "classic",    },  },]);
Namespace
await index.upsert([  {    id: "6789",    vector: [0.6, 0.7, 0.8, 0.9, 0.9],  },], { namespace: "my-namespace" });
Update Vector
await index.upsert({	id: "1234",	vector: [0.1, 0.2, 0.3, 0.4, 0.5]	metadata: {		title: "Redis"	}})await index.update({	id: "1234",	metadata: {		title: "QStash"	}})
Single Data
await index.upsert({  id: "1234",  data: "'The Lord of the Rings' follows Frodo Baggins and his allies on a quest to destroy a powerful ring and save Middle-earth from the dark lord Sauron.",  metadata: {    title: "Lord of The Rings",    genre: "drama",    category: "classic",  },});
Multiple Data
await index.upsert([  {    id: "6789",    data: "'Harry Potter' follows the journey of a young wizard, Harry Potter, as he attends Hogwarts School of Witchcraft and Wizardry, forms deep friendships, and confronts the dark wizard Voldemort, who seeks immortality and domination over the magical world.",  },  {    id: "1234",    data: "'The Lord of the Rings' follows Frodo Baggins and his allies on a quest to destroy a powerful ring and save Middle-earth from the dark lord Sauron.",    metadata: {      title: "Lord of The Rings",      genre: "drama",      category: "classic",    },  },]);
Update data
await index.upsert({	id: "1234",	data: "Upstash product"	metadata: {		title: "Redis"	}})await index.upsert({	id: "1234",	metadata: {		title: "QStash"	}})
Loading search…