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", },});
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", }, },]);
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:
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", },});
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", }, },]);