await index.upsert({
  id: "star-wars",
  content: { title: "Star Wars", genre: "sci-fi" },
  metadata: { year: 1977 }
});

Used to add new documents or update an existing document.

You can only upsert documents with the same structure as defined in your database.

Arguments

DocumentPayload
Document | Document[]
required

Response

'Success' on successful operation.

await index.upsert({
  id: "star-wars",
  content: { title: "Star Wars", genre: "sci-fi" },
  metadata: { year: 1977 }
});